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);
 }
예제 #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);
    }
예제 #3
0
파일: Profiler.php 프로젝트: ddrozdik/dmaps
 /**
  * {@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);
         }
     }
 }
예제 #4
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());
 }
예제 #5
0
 public function testCollect()
 {
     $request = new Request();
     $request->query->set('foo', 'bar');
     $response = new Response('', 204);
     $collector = new RequestDataCollector();
     $profiler = new Profiler($this->storage);
     $profiler->add($collector);
     $profile = $profiler->collect($request, $response);
     $this->assertSame(204, $profile->getStatusCode());
     $this->assertSame('GET', $profile->getMethod());
     $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
 }
예제 #6
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());
 }
예제 #7
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);
 }
 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(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';
     };
 }
예제 #10
0
 /**
  * Adds a Collector.
  *
  * @param DataCollectorInterface $collector
  * @param string                 $toolbar
  * @param string                 $panel
  * @param int                    $priority
  */
 public function add(DataCollectorInterface $collector, $toolbar = null, $panel = null, $priority = 0)
 {
     $this->viewCollectorMap[$collector->getName()] = compact('toolbar', 'panel');
     $this->order[$collector->getName()] = $priority;
     parent::add($collector);
 }
 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(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';
             }
         }
     };
 }
 /**
  * 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;
 }