collectors.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Loader\Configurator;
  11. use Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector;
  12. use Symfony\Component\HttpKernel\DataCollector\AjaxDataCollector;
  13. use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
  14. use Symfony\Component\HttpKernel\DataCollector\EventDataCollector;
  15. use Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector;
  16. use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
  17. use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector;
  18. use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
  19. use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector;
  20. use Symfony\Component\HttpKernel\KernelEvents;
  21. return static function (ContainerConfigurator $container) {
  22. $container->services()
  23. ->set('data_collector.config', ConfigDataCollector::class)
  24. ->call('setKernel', [service('kernel')->ignoreOnInvalid()])
  25. ->tag('data_collector', ['template' => '@WebProfiler/Collector/config.html.twig', 'id' => 'config', 'priority' => -255])
  26. ->set('data_collector.request', RequestDataCollector::class)
  27. ->args([
  28. service('request_stack')->ignoreOnInvalid(),
  29. ])
  30. ->tag('kernel.event_subscriber')
  31. ->tag('data_collector', ['template' => '@WebProfiler/Collector/request.html.twig', 'id' => 'request', 'priority' => 335])
  32. ->set('data_collector.request.session_collector', \Closure::class)
  33. ->factory([\Closure::class, 'fromCallable'])
  34. ->args([[service('data_collector.request'), 'collectSessionUsage']])
  35. ->set('data_collector.ajax', AjaxDataCollector::class)
  36. ->tag('data_collector', ['template' => '@WebProfiler/Collector/ajax.html.twig', 'id' => 'ajax', 'priority' => 315])
  37. ->set('data_collector.exception', ExceptionDataCollector::class)
  38. ->tag('data_collector', ['template' => '@WebProfiler/Collector/exception.html.twig', 'id' => 'exception', 'priority' => 305])
  39. ->set('data_collector.events', EventDataCollector::class)
  40. ->args([
  41. service('debug.event_dispatcher')->ignoreOnInvalid(),
  42. service('request_stack')->ignoreOnInvalid(),
  43. ])
  44. ->tag('data_collector', ['template' => '@WebProfiler/Collector/events.html.twig', 'id' => 'events', 'priority' => 290])
  45. ->set('data_collector.logger', LoggerDataCollector::class)
  46. ->args([
  47. service('logger')->ignoreOnInvalid(),
  48. sprintf('%s/%s', param('kernel.build_dir'), param('kernel.container_class')),
  49. service('request_stack')->ignoreOnInvalid(),
  50. ])
  51. ->tag('monolog.logger', ['channel' => 'profiler'])
  52. ->tag('data_collector', ['template' => '@WebProfiler/Collector/logger.html.twig', 'id' => 'logger', 'priority' => 300])
  53. ->set('data_collector.time', TimeDataCollector::class)
  54. ->args([
  55. service('kernel')->ignoreOnInvalid(),
  56. service('debug.stopwatch')->ignoreOnInvalid(),
  57. ])
  58. ->tag('data_collector', ['template' => '@WebProfiler/Collector/time.html.twig', 'id' => 'time', 'priority' => 330])
  59. ->set('data_collector.memory', MemoryDataCollector::class)
  60. ->tag('data_collector', ['template' => '@WebProfiler/Collector/memory.html.twig', 'id' => 'memory', 'priority' => 325])
  61. ->set('data_collector.router', RouterDataCollector::class)
  62. ->tag('kernel.event_listener', ['event' => KernelEvents::CONTROLLER, 'method' => 'onKernelController'])
  63. ->tag('data_collector', ['template' => '@WebProfiler/Collector/router.html.twig', 'id' => 'router', 'priority' => 285])
  64. ;
  65. };