public function details($token, $requestIndex)
 {
     $this->profiler->disable();
     $profile = $this->profiler->loadProfile($token);
     $logs = $profile->getCollector('contentful')->getLogs();
     $logEntry = $logs[$requestIndex];
     return $this->templating->renderResponse('@Contentful/Collector/details.html.twig', ['requestIndex' => $requestIndex, 'entry' => $logEntry]);
 }
 /**
  * @Web\Route("", name="_advanced_profiler")
  */
 public function indexAction()
 {
     $this->init();
     $tokens = $this->profiler->find(null, null, PHP_INT_MAX, null, null, null);
     /** @var Profile[] $profiles */
     $profiles = [];
     foreach ($tokens as $token) {
         $profiles[] = $this->profiler->loadProfile($token['token']);
     }
     return $this->render('YchuAdvancedProfilerBundle:Default:index.html.twig', ['requests' => $profiles]);
 }
 /**
  * @param $profile ->getToken()
  * @param int $qid
  *
  * @return array
  */
 private function getQuery(Profile $profile, $qid)
 {
     $this->profiler->disable();
     $token = $profile->getToken();
     if (!($profile = $this->profiler->loadProfile($token))) {
         throw new NotFoundHttpException($this->t('Token @token does not exist.', ['@token' => $token]));
     }
     /** @var DatabaseDataCollector $databaseCollector */
     $databaseCollector = $profile->getCollector('database');
     $queries = $databaseCollector->getQueries();
     $query = $queries[$qid];
     return $query;
 }
 /**
  * Get a profile's translation messages based on a previous Profiler token.
  *
  * @param string $token by which a Profile can be found in the Profiler
  *
  * @return array with collection of TransUnits and it's count
  */
 public function getByToken($token)
 {
     if (null === $this->profiler) {
         throw new \RuntimeException('Invalid profiler instance.');
     }
     $profile = $this->profiler->loadProfile($token);
     // In case no results were found
     if (!$profile instanceof Profile) {
         return array(array(), 0);
     }
     try {
         /** @var TranslationDataCollector $collector */
         $collector = $profile->getCollector('translation');
         $messages = $collector->getMessages();
         $transUnits = array();
         foreach ($messages as $message) {
             $transUnit = $this->storage->getTransUnitByKeyAndDomain($message['id'], $message['domain']);
             if ($transUnit instanceof TransUnit) {
                 $transUnits[] = $transUnit;
             } elseif (true === $this->createMissing) {
                 $transUnits[] = $transUnit = $this->transUnitManager->create($message['id'], $message['domain'], true);
             }
             // Also store the translation if profiler state was defined
             if (!$transUnit->hasTranslation($message['locale']) && $message['state'] == DataCollectorTranslator::MESSAGE_DEFINED) {
                 $this->transUnitManager->addTranslation($transUnit, $message['locale'], $message['translation'], null, true);
             }
         }
         return array($transUnits, count($transUnits));
     } catch (\InvalidArgumentException $e) {
         // Translation collector is a 2.7 feature
         return array(array(), 0);
     }
 }
Ejemplo n.º 5
0
    public function testCollect()
    {
        if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
            $this->markTestSkipped('This test requires SQLite support in your environment');
        }

        $request = new Request();
        $request->query->set('foo', 'bar');
        $response = new Response();
        $collector = new RequestDataCollector();

        $tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler');
        if (file_exists($tmp)) {
            @unlink($tmp);
        }
        $storage = new SqliteProfilerStorage('sqlite:'.$tmp);
        $storage->purge();

        $profiler = new Profiler($storage);
        $profiler->add($collector);
        $profile = $profiler->collect($request, $response);

        $profile = $profiler->loadProfile($profile->getToken());
        $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());

        @unlink($tmp);
    }
 public function details($token, $requestIndex)
 {
     $this->profiler->disable();
     $profile = $this->profiler->loadProfile($token);
     /**
      * @var CommercetoolsDataCollector $collector
      */
     $collector = $profile->getCollector('commercetools');
     $requests = $collector->getRequestInfos();
     $entry = $requests[$requestIndex];
     if (isset($entry['request']['body']) && strpos($entry['request']['body'], '{') === 0) {
         $entry['request']['body'] = json_encode(json_decode($entry['request']['body'], true), JSON_PRETTY_PRINT);
     }
     if (isset($entry['response']['body']) && strpos($entry['response']['body'], '{') === 0) {
         $entry['response']['body'] = json_encode(json_decode($entry['response']['body'], true), JSON_PRETTY_PRINT);
     }
     return $this->templating->renderResponse('@Ctp/Collector/details.html.twig', ['requestIndex' => $requestIndex, 'entry' => $entry]);
 }
Ejemplo n.º 7
0
 public function testCollect()
 {
     $request = new Request();
     $request->query->set('foo', 'bar');
     $response = new Response();
     $collector = new RequestDataCollector();
     $profiler = new Profiler($this->storage);
     $profiler->add($collector);
     $profile = $profiler->collect($request, $response);
     $profile = $profiler->loadProfile($profile->getToken());
     $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
 }
Ejemplo n.º 8
0
 public function testCollect()
 {
     $request = new Request();
     $request->query->set('foo', 'bar');
     $response = new Response();
     $collector = new RequestDataCollector();
     $tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler');
     if (file_exists($tmp)) {
         @unlink($tmp);
     }
     $storage = new SqliteProfilerStorage('sqlite:' . $tmp);
     $storage->purge();
     $profiler = new Profiler($storage);
     $profiler->add($collector);
     $profile = $profiler->collect($request, $response);
     $profile = $profiler->loadProfile($profile->getToken());
     $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
     @unlink($tmp);
 }