Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function handleException(Request $request, HttpException $exception)
 {
     $response = $this->kernel->handleException($request, $exception);
     $profile = $this->profiler->collect($request, $response, $exception);
     $this->profiler->saveProfile($profile);
     return $response;
 }
Beispiel #2
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);
     $logs = $profile->getCollector('contentful')->getLogs();
     $logEntry = $logs[$requestIndex];
     return $this->templating->renderResponse('@Contentful/Collector/details.html.twig', ['requestIndex' => $requestIndex, 'entry' => $logEntry]);
 }
 /**
  * template should be loaded for 'foo' because other collectors are
  * missing in profile or in profiler.
  */
 public function testGetTemplates()
 {
     $profile = $this->mockProfile();
     $profile->expects($this->any())->method('hasCollector')->will($this->returnCallback(array($this, 'profilerHasCallback')));
     $this->profiler->expects($this->any())->method('has')->withAnyParameters()->will($this->returnCallback(array($this, 'profileHasCollectorCallback')));
     $result = $this->templateManager->getTemplates($profile);
     $this->assertArrayHasKey('foo', $result);
     $this->assertArrayNotHasKey('bar', $result);
     $this->assertArrayNotHasKey('baz', $result);
 }
 /**
  * @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]);
 }
 private function filterResponse(FilterResponseEvent $event, \Exception $ex)
 {
     $profiler = new Profiler(new NullProfilerStorage());
     $profiler->add(new ConfigDataCollector($this->kernel));
     $profiler->add(new ExceptionDataCollector());
     $profiler->add(new RealExceptionDataCollector());
     $profiler->collect($event->getRequest(), $event->getResponse(), $ex);
     $normalizer = new ProfilerNormalizer($this->kernel);
     $listener = new ResponseListener($normalizer, $profiler);
     $listener->onCoreResponse($event);
 }
 /**
  * @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;
 }
 /**
  * Profiler constructor.
  * @param ProfilerStorageInterface $storage
  * @param LoggerInterface $logger
  * @param bool $defaultEnabled
  * @param null $class
  * @param null $dsn
  * @param null $username
  * @param null $password
  * @param int $ttl
  */
 public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger, $defaultEnabled = true, $class = null, $dsn = null, $username = null, $password = null, $ttl = 3600)
 {
     if ($defaultEnabled !== true) {
         $storage = new $class($dsn, $username, $password, $ttl);
     }
     parent::__construct($storage, $logger);
 }
Beispiel #9
0
 public function testCollect()
 {
     $request = new Request();
     $request->query->set('foo', 'bar');
     $response = new Response();
     $collector = new RequestDataCollector();
     $storage = new SQLiteProfilerStorage(sys_get_temp_dir() . '/sf2_profiler.db');
     $storage->purge(true);
     $profiler = new Profiler($storage);
     $profiler->add($collector);
     $profiler->setToken('foobar');
     $profiler->collect($request, $response);
     $profiler = new Profiler($storage);
     $profiler->setToken('foobar');
     $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
 }
Beispiel #10
0
 public function __construct(ContainerInterface $container, ProfilerStorage $profilerStorage, LoggerInterface $logger = null)
 {
     parent::__construct($profilerStorage, $logger);
     $this->container = $container;
     $this->initCollectors();
     $this->loadCollectorData();
 }
 /**
  * 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);
     }
 }
Beispiel #12
0
 public function __construct(ContainerInterface $container, ProfilerStorageInterface $storage, LoggerInterface $logger = null)
 {
     parent::__construct($storage, $logger);
     foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
         $this->add($container->get($id));
     }
 }
 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]);
 }
Beispiel #14
0
 /**
  * Updates database and all related caches according to changes of extended entities
  *
  * @param bool $warmUpConfigCache Whether the entity config cache should be warmed up
  *                                after database schema is changed
  * @param bool $updateRouting     Whether routes should be updated after database schema is changed
  *
  * @return bool
  */
 public function updateDatabase($warmUpConfigCache = false, $updateRouting = false)
 {
     set_time_limit(0);
     // disable Profiler to avoid an exception in DoctrineDataCollector
     // in case if entity classes and Doctrine metadata are not match each other in the current process
     if ($this->profiler) {
         $this->profiler->disable();
     }
     $this->maintenance->activate();
     $commands = ['oro:entity-extend:update-config' => [], 'oro:entity-extend:cache:warmup' => [], 'oro:entity-extend:update-schema' => []];
     if ($warmUpConfigCache) {
         $commands = array_merge($commands, ['oro:entity-config:cache:warmup' => []]);
     }
     if ($updateRouting) {
         $commands = array_merge($commands, ['router:cache:clear' => [], 'fos:js-routing:dump' => []]);
     }
     return $this->executeCommands($commands);
 }
Beispiel #15
0
 /**
  * Gets the Collectors ordered by priority.
  *
  * @return array An array of collectors
  */
 public function all()
 {
     arsort($this->order);
     $collectors = [];
     foreach ($this->order as $name => $priority) {
         $collectors[$name] = parent::get($name);
     }
     return $collectors;
 }
 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);
 }
Beispiel #17
0
 /**
  * @return \Swift_Mime_Message[]
  */
 private function getMessages()
 {
     /** @var Client $client */
     $client = $this->getClient();
     $client->followRedirects(false);
     $messages = [];
     do {
         $client->back();
         $response = $client->getResponse();
         $profile = $this->symfonyProfiler->loadProfileFromResponse($response);
         if (false === $profile) {
             continue;
         }
         $swiftMailerCollector = $profile->getCollector('swiftmailer');
         $messages = array_merge($messages, $swiftMailerCollector->getMessages());
     } while (empty($messages));
     $client->followRedirects();
     return $messages;
 }
Beispiel #18
0
 /**
  * {@inheritdoc}
  */
 public function add(DataCollectorInterface $collector)
 {
     // drupal collector should not be disabled
     if ($collector->getName() == 'drupal') {
         parent::add($collector);
     } else {
         if ($this->activeToolbarItems && array_key_exists($collector->getName(), $this->activeToolbarItems) && $this->activeToolbarItems[$collector->getName()] !== '0') {
             parent::add($collector);
         }
     }
 }
Beispiel #19
0
 /**
  * Gets template names of templates that are present in the viewed profile.
  *
  * @param \Symfony\Component\HttpKernel\Profiler\Profile $profile
  *
  * @return array
  *
  * @throws \UnexpectedValueException
  */
 protected function getNames(Profile $profile)
 {
     $templates = [];
     foreach ($this->templates as $arguments) {
         if (NULL === $arguments) {
             continue;
         }
         list($name, $template) = $arguments;
         if (!$this->profiler->has($name) || !$profile->hasCollector($name)) {
             continue;
         }
         if ('.html.twig' === substr($template, -10)) {
             $template = substr($template, 0, -10);
         }
         if (!$this->twigLoader->exists($template . '.html.twig')) {
             throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
         }
         $templates[$name] = $template . '.html.twig';
     }
     return $templates;
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param  Application $app
  * @throws \Exception
  */
 public function register(Application $app)
 {
     $app['profiler.mount_prefix'] = '/_profiler';
     $app['data_collector.templates'] = $app->share(function () {
         $templates = array(array('config', '@WebProfiler/Collector/config.html.twig'), array('request', '@WebProfiler/Collector/request.html.twig'), array('exception', '@WebProfiler/Collector/exception.html.twig'), array('events', '@WebProfiler/Collector/events.html.twig'), array('logger', '@WebProfiler/Collector/logger.html.twig'), array('time', '@WebProfiler/Collector/time.html.twig'), array('router', '@WebProfiler/Collector/router.html.twig'), array('memory', '@WebProfiler/Collector/memory.html.twig'), array('form', '@WebProfiler/Collector/form.html.twig'));
         if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
             $templates[] = array('twig', '@WebProfiler/Collector/twig.html.twig');
         }
         return $templates;
     });
     $app['data_collectors'] = $app->share(function ($app) {
         return array('config' => $app->share(function ($app) {
             return new ConfigDataCollector();
         }), 'request' => $app->share(function ($app) {
             return new RequestDataCollector();
         }), 'exception' => $app->share(function ($app) {
             return new ExceptionDataCollector();
         }), 'events' => $app->share(function ($app) {
             return new EventDataCollector($app['dispatcher']);
         }), 'logger' => $app->share(function ($app) {
             return new LoggerDataCollector($app['logger']);
         }), 'time' => $app->share(function ($app) {
             return new TimeDataCollector(null, $app['stopwatch']);
         }), 'router' => $app->share(function ($app) {
             return new RouterDataCollector();
         }), 'memory' => $app->share(function ($app) {
             return new MemoryDataCollector();
         }));
     });
     if (isset($app['form.resolved_type_factory']) && class_exists('\\Symfony\\Component\\Form\\Extension\\DataCollector\\FormDataCollector')) {
         $app['data_collectors.form.extractor'] = $app->share(function () {
             return new FormDataExtractor();
         });
     }
     if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
         $app['twig.profiler.profile'] = $app->share(function () {
             return new \Twig_Profiler_Profile();
         });
     }
     $app['web_profiler.controller.profiler'] = $app->share(function ($app) {
         return new ProfilerController($app['url_generator'], $app['profiler'], $app['twig'], $app['data_collector.templates'], $app['web_profiler.debug_toolbar.position']);
     });
     $app['web_profiler.controller.router'] = $app->share(function ($app) {
         return new RouterController($app['profiler'], $app['twig'], isset($app['url_matcher']) ? $app['url_matcher'] : null, $app['routes']);
     });
     $app['web_profiler.controller.exception'] = $app->share(function ($app) {
         return new ExceptionController($app['profiler'], $app['twig'], $app['debug']);
     });
     $app['web_profiler.toolbar.listener'] = $app->share(function ($app) {
         return new WebDebugToolbarListener($app['twig'], $app['web_profiler.debug_toolbar.intercept_redirects'], $app['web_profiler.debug_toolbar.position'], $app['url_generator']);
     });
     $app['profiler'] = $app->share(function ($app) {
         $profiler = new Profiler($app['profiler.storage'], $app['logger']);
         foreach ($app['data_collectors'] as $collector) {
             $profiler->add($collector($app));
         }
         return $profiler;
     });
     $app['profiler.storage'] = $app->share(function ($app) {
         return new FileProfilerStorage('file:' . $app['profiler.cache_dir']);
     });
     $app['profiler.request_matcher'] = null;
     $app['profiler.only_exceptions'] = false;
     $app['profiler.only_master_requests'] = false;
     $app['web_profiler.debug_toolbar.enable'] = true;
     $app['web_profiler.debug_toolbar.position'] = 'bottom';
     $app['web_profiler.debug_toolbar.intercept_redirects'] = false;
     $app['profiler.listener'] = $app->share(function ($app) {
         return new ProfilerListener($app['profiler'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests'], $app['request_stack']);
     });
     $app['stopwatch'] = $app->share(function () {
         return new Stopwatch();
     });
     $app['code.file_link_format'] = null;
 }
 /**
  * Purges profiles.
  */
 public function purge(array &$form, FormStateInterface $form_state)
 {
     $this->profiler->purge();
     drupal_set_message($this->t('Profiles purged'));
 }
Beispiel #22
0
 public function testFindWorksWithStatusCode()
 {
     $profiler = new Profiler($this->storage);
     $this->assertCount(0, $profiler->find(null, null, null, null, null, null, '204'));
 }
 public function register(Application $app)
 {
     $app['profiler.mount_prefix'] = '/_profiler';
     $app['dispatcher'] = $app->share($app->extend('dispatcher', function ($dispatcher, $app) {
         return new TraceableEventDispatcher($dispatcher, $app['stopwatch'], $app['logger']);
     }));
     $app['data_collector.templates'] = $app->share(function () {
         $templates = array(array('config', '@WebProfiler/Collector/config.html.twig'), array('request', '@WebProfiler/Collector/request.html.twig'), array('exception', '@WebProfiler/Collector/exception.html.twig'), array('events', '@WebProfiler/Collector/events.html.twig'), array('logger', '@WebProfiler/Collector/logger.html.twig'), array('time', '@WebProfiler/Collector/time.html.twig'), array('router', '@WebProfiler/Collector/router.html.twig'), array('memory', '@WebProfiler/Collector/memory.html.twig'), array('form', '@WebProfiler/Collector/form.html.twig'));
         if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
             $templates[] = array('twig', '@WebProfiler/Collector/twig.html.twig');
         }
         return $templates;
     });
     $app['data_collectors'] = $app->share(function ($app) {
         return array('config' => $app->share(function ($app) {
             return new ConfigDataCollector();
         }), 'request' => $app->share(function ($app) {
             return new RequestDataCollector();
         }), 'exception' => $app->share(function ($app) {
             return new ExceptionDataCollector();
         }), 'events' => $app->share(function ($app) {
             return new EventDataCollector($app['dispatcher']);
         }), 'logger' => $app->share(function ($app) {
             return new LoggerDataCollector($app['logger']);
         }), 'time' => $app->share(function ($app) {
             return new TimeDataCollector(null, $app['stopwatch']);
         }), 'router' => $app->share(function ($app) {
             return new RouterDataCollector();
         }), 'memory' => $app->share(function ($app) {
             return new MemoryDataCollector();
         }));
     });
     if (isset($app['form.resolved_type_factory']) && class_exists('\\Symfony\\Component\\Form\\Extension\\DataCollector\\FormDataCollector')) {
         $app['data_collectors.form.extractor'] = $app->share(function () {
             return new FormDataExtractor();
         });
         $app['data_collectors'] = $app->share($app->extend('data_collectors', function ($collectors, $app) {
             $collectors['form'] = $app->share(function ($app) {
                 return new FormDataCollector($app['data_collectors.form.extractor']);
             });
             return $collectors;
         }));
         $app['form.resolved_type_factory'] = $app->share($app->extend('form.resolved_type_factory', function ($factory, $app) {
             return new ResolvedTypeFactoryDataCollectorProxy($factory, $app['data_collectors']['form']($app));
         }));
         $app['form.type.extensions'] = $app->share($app->extend('form.type.extensions', function ($extensions, $app) {
             $extensions[] = new DataCollectorTypeExtension($app['data_collectors']['form']($app));
             return $extensions;
         }));
     }
     if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
         $app['data_collectors'] = $app->share($app->extend('data_collectors', function ($collectors, $app) {
             $collectors['twig'] = $app->share(function ($app) {
                 return new TwigDataCollector($app['twig.profiler.profile']);
             });
             return $collectors;
         }));
         $app['twig.profiler.profile'] = $app->share(function () {
             return new \Twig_Profiler_Profile();
         });
     }
     $app['web_profiler.controller.profiler'] = $app->share(function ($app) {
         return new ProfilerController($app['url_generator'], $app['profiler'], $app['twig'], $app['data_collector.templates'], $app['web_profiler.debug_toolbar.position']);
     });
     $app['web_profiler.controller.router'] = $app->share(function ($app) {
         return new RouterController($app['profiler'], $app['twig'], isset($app['url_matcher']) ? $app['url_matcher'] : null, $app['routes']);
     });
     $app['web_profiler.controller.exception'] = $app->share(function ($app) {
         return new ExceptionController($app['profiler'], $app['twig'], $app['debug']);
     });
     $app['web_profiler.toolbar.listener'] = $app->share(function ($app) {
         return new WebDebugToolbarListener($app['twig'], $app['web_profiler.debug_toolbar.intercept_redirects'], $app['web_profiler.debug_toolbar.position'], $app['url_generator']);
     });
     $app['profiler'] = $app->share(function ($app) {
         $profiler = new Profiler($app['profiler.storage'], $app['logger']);
         foreach ($app['data_collectors'] as $collector) {
             $profiler->add($collector($app));
         }
         return $profiler;
     });
     $app['profiler.storage'] = $app->share(function ($app) {
         return new FileProfilerStorage('file:' . $app['profiler.cache_dir']);
     });
     $app['profiler.request_matcher'] = null;
     $app['profiler.only_exceptions'] = false;
     $app['profiler.only_master_requests'] = false;
     $app['web_profiler.debug_toolbar.enable'] = true;
     $app['web_profiler.debug_toolbar.position'] = 'bottom';
     $app['web_profiler.debug_toolbar.intercept_redirects'] = false;
     $app['profiler.listener'] = $app->share(function ($app) {
         if (Kernel::VERSION_ID >= 20800) {
             return new ProfilerListener($app['profiler'], $app['request_stack'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests']);
         } else {
             return new ProfilerListener($app['profiler'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests'], $app['request_stack']);
         }
     });
     $app['stopwatch'] = $app->share(function () {
         return new Stopwatch();
     });
     $app['code.file_link_format'] = null;
     $app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
         $twig->addExtension(new CodeExtension($app['code.file_link_format'], '', $app['charset']));
         if (class_exists('\\Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension')) {
             $twig->addExtension(new WebProfilerExtension());
         }
         if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
             $twig->addExtension(new ProfilerExtension($app['twig.profiler.profile'], $app['stopwatch']));
         }
         return $twig;
     }));
     $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
         $loader->addPath($app['profiler.templates_path'], 'WebProfiler');
         return $loader;
     }));
     $app['profiler.templates_path'] = function () {
         $r = new \ReflectionClass('Symfony\\Bundle\\WebProfilerBundle\\EventListener\\WebDebugToolbarListener');
         return dirname(dirname($r->getFileName())) . '/Resources/views';
     };
 }
 public function register(Container $app)
 {
     $app['profiler.mount_prefix'] = '/_profiler';
     $app->extend('dispatcher', function ($dispatcher, $app) {
         return new TraceableEventDispatcher($dispatcher, $app['stopwatch'], $app['logger']);
     });
     $app['data_collector.templates'] = function ($app) {
         $templates = array(array('config', '@WebProfiler/Collector/config.html.twig'), array('request', '@WebProfiler/Collector/request.html.twig'), array('exception', '@WebProfiler/Collector/exception.html.twig'), array('events', '@WebProfiler/Collector/events.html.twig'), array('logger', '@WebProfiler/Collector/logger.html.twig'), array('time', '@WebProfiler/Collector/time.html.twig'), array('router', '@WebProfiler/Collector/router.html.twig'), array('memory', '@WebProfiler/Collector/memory.html.twig'), array('form', '@WebProfiler/Collector/form.html.twig'));
         if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
             $templates[] = array('twig', '@WebProfiler/Collector/twig.html.twig');
         }
         if (isset($app['var_dumper.cli_dumper']) && $app['profiler.templates_path.debug']) {
             $templates[] = array('dump', '@Debug/Profiler/dump.html.twig');
         }
         if (class_exists('Symfony\\Component\\HttpKernel\\DataCollector\\AjaxDataCollector')) {
             $templates[] = array('ajax', '@WebProfiler/Collector/ajax.html.twig');
         }
         return $templates;
     };
     $app['data_collectors'] = function ($app) {
         return array('config' => function ($app) {
             return new ConfigDataCollector('Silex', Application::VERSION);
         }, 'request' => function ($app) {
             return new RequestDataCollector();
         }, 'exception' => function ($app) {
             return new ExceptionDataCollector();
         }, 'events' => function ($app) {
             return new EventDataCollector($app['dispatcher']);
         }, 'logger' => function ($app) {
             return new LoggerDataCollector($app['logger']);
         }, 'time' => function ($app) {
             return new TimeDataCollector(null, $app['stopwatch']);
         }, 'router' => function ($app) {
             return new RouterDataCollector();
         }, 'memory' => function ($app) {
             return new MemoryDataCollector();
         });
     };
     if (isset($app['form.resolved_type_factory']) && class_exists('\\Symfony\\Component\\Form\\Extension\\DataCollector\\FormDataCollector')) {
         $app['data_collectors.form.extractor'] = function () {
             return new FormDataExtractor();
         };
         $app->extend('data_collectors', function ($collectors, $app) {
             $collectors['form'] = function ($app) {
                 return new FormDataCollector($app['data_collectors.form.extractor']);
             };
             return $collectors;
         });
         $app->extend('form.resolved_type_factory', function ($factory, $app) {
             return new ResolvedTypeFactoryDataCollectorProxy($factory, $app['data_collectors']['form']($app));
         });
         $app->extend('form.type.extensions', function ($extensions, $app) {
             $extensions[] = new DataCollectorTypeExtension($app['data_collectors']['form']($app));
             return $extensions;
         });
     }
     if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
         $app['data_collectors'] = $app->extend('data_collectors', function ($collectors, $app) {
             $collectors['twig'] = function ($app) {
                 return new TwigDataCollector($app['twig.profiler.profile']);
             };
             return $collectors;
         });
         $app['twig.profiler.profile'] = function () {
             return new \Twig_Profiler_Profile();
         };
     }
     if (isset($app['var_dumper.cli_dumper'])) {
         $app['var_dumper.dump_listener'] = function ($app) {
             return new DumpListener($app['var_dumper.cloner'], $app['var_dumper.data_collector']);
         };
         $app['data_collectors'] = $app->extend('data_collectors', function ($collectors, $app) {
             if ($app['profiler.templates_path.debug']) {
                 $collectors['dump'] = function ($app) {
                     $dumper = null === $app['var_dumper.dump_destination'] ? null : $app['var_dumper.cli_dumper'];
                     return $app['var_dumper.data_collector'] = new DumpDataCollector($app['stopwatch'], null, $app['charset'], $app['request_stack'], $dumper);
                 };
             }
             return $collectors;
         });
     }
     if (class_exists('Symfony\\Component\\HttpKernel\\DataCollector\\AjaxDataCollector')) {
         $app['data_collectors'] = $app->extend('data_collectors', function ($collectors, $app) {
             $collectors['ajax'] = function ($app) {
                 return new AjaxDataCollector();
             };
             return $collectors;
         });
     }
     $app['web_profiler.controller.profiler'] = function ($app) {
         return new ProfilerController($app['url_generator'], $app['profiler'], $app['twig'], $app['data_collector.templates'], $app['web_profiler.debug_toolbar.position']);
     };
     $app['web_profiler.controller.router'] = function ($app) {
         return new RouterController($app['profiler'], $app['twig'], isset($app['request_matcher']) ? $app['request_matcher'] : null, $app['routes']);
     };
     $app['web_profiler.controller.exception'] = function ($app) {
         return new ExceptionController($app['profiler'], $app['twig'], $app['debug']);
     };
     $app['web_profiler.toolbar.listener'] = function ($app) {
         $mode = $app['web_profiler.debug_toolbar.enable'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED;
         return new WebDebugToolbarListener($app['twig'], $app['web_profiler.debug_toolbar.intercept_redirects'], $mode, $app['web_profiler.debug_toolbar.position'], $app['url_generator']);
     };
     $app['profiler'] = function ($app) {
         $profiler = new Profiler($app['profiler.storage'], $app['logger']);
         foreach ($app['data_collectors'] as $collector) {
             $profiler->add($collector($app));
         }
         return $profiler;
     };
     $app['profiler.storage'] = function ($app) {
         return new FileProfilerStorage('file:' . $app['profiler.cache_dir']);
     };
     $app['profiler.request_matcher'] = null;
     $app['profiler.only_exceptions'] = false;
     $app['profiler.only_master_requests'] = false;
     $app['web_profiler.debug_toolbar.enable'] = true;
     $app['web_profiler.debug_toolbar.position'] = 'bottom';
     $app['web_profiler.debug_toolbar.intercept_redirects'] = false;
     $app['profiler.listener'] = function ($app) {
         if (Kernel::VERSION_ID >= 20800) {
             return new ProfilerListener($app['profiler'], $app['request_stack'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests']);
         } else {
             return new ProfilerListener($app['profiler'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests'], $app['request_stack']);
         }
     };
     $app['stopwatch'] = function () {
         return new Stopwatch();
     };
     $app['code.file_link_format'] = null;
     $app->extend('twig', function ($twig, $app) {
         $twig->addExtension(new CodeExtension($app['code.file_link_format'], '', $app['charset']));
         if (class_exists('\\Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension')) {
             $twig->addExtension(new WebProfilerExtension());
         }
         if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
             $twig->addExtension(new ProfilerExtension($app['twig.profiler.profile'], $app['stopwatch']));
         }
         return $twig;
     });
     $app->extend('twig.loader.filesystem', function ($loader, $app) {
         $loader->addPath($app['profiler.templates_path'], 'WebProfiler');
         if ($app['profiler.templates_path.debug']) {
             $loader->addPath($app['profiler.templates_path.debug'], 'Debug');
         }
         return $loader;
     });
     $app['profiler.templates_path'] = function () {
         $r = new \ReflectionClass('Symfony\\Bundle\\WebProfilerBundle\\EventListener\\WebDebugToolbarListener');
         return dirname(dirname($r->getFileName())) . '/Resources/views';
     };
     $app['profiler.templates_path.debug'] = function () {
         foreach (spl_autoload_functions() as $autoloader) {
             if (!is_array($autoloader) || !method_exists($autoloader[0], 'findFile')) {
                 continue;
             }
             if ($file = $autoloader[0]->findFile('Symfony\\Bundle\\DebugBundle\\DebugBundle')) {
                 return dirname($file) . '/Resources/views';
             }
         }
     };
 }
 public function register(Application $app)
 {
     $app['dispatcher'] = $app->share($app->extend('dispatcher', function ($dispatcher, $app) {
         $dispatcher = new TraceableEventDispatcher($dispatcher, $app['stopwatch'], $app['logger']);
         $dispatcher->setProfiler($app['profiler']);
         return $dispatcher;
     }));
     $app['data_collector.templates'] = array(array('config', '@WebProfiler/Collector/config.html.twig'), array('request', '@WebProfiler/Collector/request.html.twig'), array('exception', '@WebProfiler/Collector/exception.html.twig'), array('events', '@WebProfiler/Collector/events.html.twig'), array('logger', '@WebProfiler/Collector/logger.html.twig'), array('time', '@WebProfiler/Collector/time.html.twig'), array('router', '@WebProfiler/Collector/router.html.twig'), array('memory', '@WebProfiler/Collector/memory.html.twig'));
     $app['data_collectors'] = array('config' => $app->share(function ($app) {
         return new ConfigDataCollector();
     }), 'request' => $app->share(function ($app) {
         return new RequestDataCollector($app);
     }), 'exception' => $app->share(function ($app) {
         return new ExceptionDataCollector();
     }), 'events' => $app->share(function ($app) {
         return new EventDataCollector();
     }), 'logger' => $app->share(function ($app) {
         return new LoggerDataCollector($app['logger']);
     }), 'time' => $app->share(function ($app) {
         return new TimeDataCollector();
     }), 'router' => $app->share(function ($app) {
         return new RouterDataCollector();
     }), 'memory' => $app->share(function ($app) {
         return new MemoryDataCollector();
     }));
     $app['web_profiler.controller.profiler'] = $app->share(function ($app) {
         return new ProfilerController($app['url_generator'], $app['profiler'], $app['twig'], $app['data_collector.templates'], $app['web_profiler.debug_toolbar.position']);
     });
     $app['web_profiler.controller.router'] = $app->share(function ($app) {
         return new RouterController($app['profiler'], $app['twig'], isset($app['url_matcher']) ? $app['url_matcher'] : null, $app['routes']);
     });
     $app['web_profiler.controller.exception'] = $app->share(function ($app) {
         return new ExceptionController($app['profiler'], $app['twig'], $app['debug']);
     });
     $app['web_profiler.toolbar.listener'] = $app->share(function ($app) {
         return new WebDebugToolbarListener($app['twig']);
     });
     $app['web_profiler.debug_toolbar.position'] = 'bottom';
     $app['profiler'] = $app->share(function ($app) {
         $profiler = new Profiler($app['profiler.storage'], $app['logger']);
         foreach ($app['data_collectors'] as $collector) {
             $profiler->add($collector($app));
         }
         return $profiler;
     });
     $app['profiler.storage'] = $app->share(function ($app) {
         return new FileProfilerStorage('file:' . $app['profiler.cache_dir']);
     });
     $app['profiler.request_matcher'] = null;
     $app['profiler.only_exceptions'] = false;
     $app['profiler.only_master_requests'] = false;
     $app['profiler.listener'] = $app->share(function ($app) {
         return new ProfilerListener($app['profiler'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests']);
     });
     $app['stopwatch'] = $app->share(function () {
         return new Stopwatch();
     });
     $app['code.file_link_format'] = null;
     $app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
         $twig->addExtension(new CodeExtension($app['code.file_link_format'], '', $app['charset']));
         return $twig;
     }));
     $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
         $loader->addPath($app['profiler.templates_path'], 'WebProfiler');
         return $loader;
     }));
     $app['profiler.templates_path'] = function () {
         $r = new \ReflectionClass('Symfony\\Bundle\\WebProfilerBundle\\EventListener\\WebDebugToolbarListener');
         return dirname(dirname($r->getFileName())) . '/Resources/views';
     };
 }
 public function register(Container $app)
 {
     $app['profiler.mount_prefix'] = '/_profiler';
     $app->extend('dispatcher', function ($dispatcher, $app) {
         return new TraceableEventDispatcher($dispatcher, $app['stopwatch'], $app['logger']);
     });
     $app['data_collector.templates'] = function ($app) {
         $templates = [['config', '@WebProfiler/Collector/config.html.twig'], ['request', '@WebProfiler/Collector/request.html.twig'], ['exception', '@WebProfiler/Collector/exception.html.twig'], ['events', '@WebProfiler/Collector/events.html.twig'], ['logger', '@WebProfiler/Collector/logger.html.twig'], ['time', '@WebProfiler/Collector/time.html.twig'], ['router', '@WebProfiler/Collector/router.html.twig'], ['memory', '@WebProfiler/Collector/memory.html.twig'], ['form', '@WebProfiler/Collector/form.html.twig']];
         if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
             $templates[] = ['twig', '@WebProfiler/Collector/twig.html.twig'];
         }
         if (isset($app['var_dumper.cli_dumper']) && $app['profiler.templates_path.debug']) {
             $templates[] = ['dump', '@Debug/Profiler/dump.html.twig'];
         }
         if (class_exists('Symfony\\Component\\HttpKernel\\DataCollector\\AjaxDataCollector')) {
             $templates[] = ['ajax', '@WebProfiler/Collector/ajax.html.twig'];
         }
         return $templates;
     };
     $app['data_collectors'] = function ($app) {
         return ['config' => function ($app) {
             return new ConfigDataCollector('Formula Nine', NineApplication::VERSION);
         }, 'request' => function ($app) {
             return new RequestDataCollector();
         }, 'exception' => function ($app) {
             return new ExceptionDataCollector();
         }, 'events' => function ($app) {
             return new EventDataCollector($app['dispatcher']);
         }, 'logger' => function ($app) {
             return new LoggerDataCollector($app['logger']);
         }, 'time' => function ($app) {
             return new TimeDataCollector(NULL, $app['stopwatch']);
         }, 'router' => function ($app) {
             return new RouterDataCollector();
         }, 'memory' => function ($app) {
             return new MemoryDataCollector();
         }];
     };
     if (isset($app['form.resolved_type_factory']) && class_exists('\\Symfony\\Component\\Form\\Extension\\DataCollector\\FormDataCollector')) {
         $app['data_collectors.form.extractor'] = function () {
             return new FormDataExtractor();
         };
         $app->extend('data_collectors', function ($collectors, $app) {
             $collectors['form'] = function ($app) {
                 return new FormDataCollector($app['data_collectors.form.extractor']);
             };
             return $collectors;
         });
         $app->extend('form.resolved_type_factory', function ($factory, $app) {
             return new ResolvedTypeFactoryDataCollectorProxy($factory, $app['data_collectors']['form']($app));
         });
         $app->extend('form.type.extensions', function ($extensions, $app) {
             $extensions[] = new DataCollectorTypeExtension($app['data_collectors']['form']($app));
             return $extensions;
         });
     }
     if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
         $app['data_collectors'] = $app->extend('data_collectors', function ($collectors, $app) {
             $collectors['twig'] = function ($app) {
                 return new TwigDataCollector($app['twig.profiler.profile']);
             };
             return $collectors;
         });
         $app['twig.profiler.profile'] = function () {
             return new \Twig_Profiler_Profile();
         };
     }
     if (isset($app['var_dumper.cli_dumper'])) {
         $app['var_dumper.dump_listener'] = function ($app) {
             return new DumpListener($app['var_dumper.cloner'], $app['var_dumper.data_collector']);
         };
         $app['data_collectors'] = $app->extend('data_collectors', function ($collectors, $app) {
             if ($app['profiler.templates_path.debug']) {
                 $collectors['dump'] = function ($app) {
                     $dumper = NULL === $app['var_dumper.dump_destination'] ? NULL : $app['var_dumper.cli_dumper'];
                     return $app['var_dumper.data_collector'] = new DumpDataCollector($app['stopwatch'], NULL, $app['charset'], $app['request_stack'], $dumper);
                 };
             }
             return $collectors;
         });
     }
     if (class_exists('Symfony\\Component\\HttpKernel\\DataCollector\\AjaxDataCollector')) {
         $app['data_collectors'] = $app->extend('data_collectors', function ($collectors, $app) {
             $collectors['ajax'] = function ($app) {
                 return new AjaxDataCollector();
             };
             return $collectors;
         });
     }
     if (isset($app['security.token_storage']) && class_exists('Symfony\\Bundle\\SecurityBundle\\DataCollector\\SecurityDataCollector')) {
         $app->extend('data_collectors', function ($collectors, $app) {
             $collectors['security'] = function ($app) {
                 $roleHierarchy = !empty($app['security.role_hierarchy']) ? $app['security.role_hierarchy'] : NULL;
                 $logoutUrlGenerator = new LogoutUrlGenerator($app['request_stack'], $app['url_generator'], $app['security.token_storage']);
                 $sec_data_collector = 'Symfony\\Bundle\\SecurityBundle\\DataCollector\\SecurityDataCollector';
                 return new $sec_data_collector($app['security.token_storage'], $roleHierarchy, $logoutUrlGenerator);
             };
             return $collectors;
         });
         $app->extend('data_collector.templates', function ($templates) {
             $templates[] = ['security', '@Security/Collector/security.html.twig'];
             return $templates;
         });
         $app->extend('twig.loader.filesystem', function ($loader, $app) {
             if ($app['profiler.templates_path.security']) {
                 $loader->addPath($app['profiler.templates_path.security'], 'Security');
             }
             return $loader;
         });
         $app['profiler.templates_path.security'] = function () {
             $r = new \ReflectionClass('Symfony\\Bundle\\SecurityBundle\\DataCollector\\SecurityDataCollector');
             return dirname(dirname($r->getFileName())) . '/Resources/views';
         };
         $app['twig'] = $app->extend('twig', function ($twig, $app) {
             $twig->addFilter('yaml_encode', new \Twig_SimpleFilter('yaml_encode', function (array $var) {
                 return Yaml::dump($var);
             }));
             $twig->addFunction('yaml_encode', new \Twig_SimpleFunction('yaml_encode', function (array $var) {
                 return Yaml::dump($var);
             }));
             return $twig;
         });
     }
     $app['web_profiler.controller.profiler'] = function ($app) {
         return new ProfilerController($app['url_generator'], $app['profiler'], $app['twig'], $app['data_collector.templates'], $app['web_profiler.debug_toolbar.position']);
     };
     $app['web_profiler.controller.router'] = function ($app) {
         return new RouterController($app['profiler'], $app['twig'], $app['request_matcher'] ?? NULL, $app['routes']);
     };
     $app['web_profiler.controller.exception'] = function ($app) {
         return new ExceptionController($app['profiler'], $app['twig'], $app['debug']);
     };
     $app['web_profiler.toolbar.listener'] = function ($app) {
         $mode = $app['web_profiler.debug_toolbar.enable'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED;
         return new WebDebugToolbarListener($app['twig'], $app['web_profiler.debug_toolbar.intercept_redirects'], $mode, $app['web_profiler.debug_toolbar.position'], $app['url_generator']);
     };
     $app['profiler'] = function ($app) {
         $profiler = new Profiler($app['profiler.storage'], $app['logger']);
         foreach ($app['data_collectors'] as $collector) {
             /** @var callable $collector */
             $profiler->add($collector($app));
         }
         return $profiler;
     };
     $app['profiler.storage'] = function ($app) {
         return new FileProfilerStorage('file:' . $app['profiler.cache_dir']);
     };
     $app['profiler.request_matcher'] = NULL;
     $app['profiler.only_exceptions'] = FALSE;
     $app['profiler.only_master_requests'] = FALSE;
     $app['web_profiler.debug_toolbar.enable'] = TRUE;
     $app['web_profiler.debug_toolbar.position'] = 'bottom';
     $app['web_profiler.debug_toolbar.intercept_redirects'] = FALSE;
     $app['profiler.listener'] = function ($app) {
         if (Kernel::VERSION_ID >= 20800) {
             return new ProfilerListener($app['profiler'], $app['request_stack'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests']);
         } else {
             /** @noinspection PhpParamsInspection */
             return new ProfilerListener($app['profiler'], $app['profiler.request_matcher'], $app['profiler.only_exceptions'], $app['profiler.only_master_requests'], $app['request_stack']);
         }
     };
     $app['stopwatch'] = function () {
         return new Stopwatch();
     };
     $app['code.file_link_format'] = NULL;
     $app->extend('twig', function ($twig, $app) {
         $twig->addExtension(new CodeExtension($app['code.file_link_format'], '', $app['charset']));
         if (class_exists('\\Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension')) {
             $twig->addExtension(new WebProfilerExtension());
         }
         if (class_exists('Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension')) {
             $twig->addExtension(new ProfilerExtension($app['twig.profiler.profile'], $app['stopwatch']));
         }
         return $twig;
     });
     $app->extend('twig.loader.filesystem', function ($loader, $app) {
         $loader->addPath($app['profiler.templates_path'], 'WebProfiler');
         if ($app['profiler.templates_path.debug']) {
             $loader->addPath($app['profiler.templates_path.debug'], 'Debug');
         }
         return $loader;
     });
     $app['profiler.templates_path'] = function () {
         $r = new \ReflectionClass('Symfony\\Bundle\\WebProfilerBundle\\EventListener\\WebDebugToolbarListener');
         return dirname(dirname($r->getFileName())) . '/Resources/views';
     };
     $app['profiler.templates_path.debug'] = function () {
         foreach (spl_autoload_functions() as $autoloader) {
             if (!is_array($autoloader) || !method_exists($autoloader[0], 'findFile')) {
                 continue;
             }
             if ($file = $autoloader[0]->{'findFile'}('Symfony\\Bundle\\DebugBundle\\DebugBundle')) {
                 return dirname($file) . '/Resources/views';
             }
         }
     };
 }
 public function testFindWorksWithInvalidDates()
 {
     $profiler = new Profiler($this->storage);
     $this->assertCount(0, $profiler->find(null, null, null, null, 'some string', ''));
 }
 /**
  * @param string $ip
  * @param string $url
  * @param int    $limit
  * @param string $method
  * @param string $start
  * @param string $end
  * @return array
  */
 public function find($ip = null, $url = null, $limit = null, $method = null, $start = null, $end = null)
 {
     $limit = $limit ?: $this->defaultLimit;
     return $this->profiler->find($ip, $url, $limit, $method, $start, $end);
 }