profiler.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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\WebProfilerBundle\Controller\ExceptionPanelController;
  12. use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController;
  13. use Symfony\Bundle\WebProfilerBundle\Controller\RouterController;
  14. use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
  15. use Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator;
  16. use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension;
  17. use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
  18. use Symfony\Component\VarDumper\Dumper\HtmlDumper;
  19. return static function (ContainerConfigurator $container) {
  20. $container->services()
  21. ->set('web_profiler.controller.profiler', ProfilerController::class)
  22. ->public()
  23. ->args([
  24. service('router')->nullOnInvalid(),
  25. service('profiler')->nullOnInvalid(),
  26. service('twig'),
  27. param('data_collector.templates'),
  28. service('web_profiler.csp.handler'),
  29. param('kernel.project_dir'),
  30. ])
  31. ->set('web_profiler.controller.router', RouterController::class)
  32. ->public()
  33. ->args([
  34. service('profiler')->nullOnInvalid(),
  35. service('twig'),
  36. service('router')->nullOnInvalid(),
  37. null,
  38. tagged_iterator('routing.expression_language_provider'),
  39. ])
  40. ->set('web_profiler.controller.exception_panel', ExceptionPanelController::class)
  41. ->public()
  42. ->args([
  43. service('error_handler.error_renderer.html'),
  44. service('profiler')->nullOnInvalid(),
  45. ])
  46. ->set('web_profiler.csp.handler', ContentSecurityPolicyHandler::class)
  47. ->args([
  48. inline_service(NonceGenerator::class),
  49. ])
  50. ->set('twig.extension.webprofiler', WebProfilerExtension::class)
  51. ->args([
  52. inline_service(HtmlDumper::class)
  53. ->args([null, param('kernel.charset'), HtmlDumper::DUMP_LIGHT_ARRAY])
  54. ->call('setDisplayOptions', [['maxStringLength' => 4096, 'fileLinkFormat' => service('debug.file_link_formatter')]]),
  55. ])
  56. ->tag('twig.extension')
  57. ->set('debug.file_link_formatter', FileLinkFormatter::class)
  58. ->args([
  59. param('debug.file_link_format'),
  60. service('request_stack')->ignoreOnInvalid(),
  61. param('kernel.project_dir'),
  62. '/_profiler/open?file=%%f&line=%%l#line%%l',
  63. ])
  64. ->set('debug.file_link_formatter.url_format', 'string')
  65. ->factory([FileLinkFormatter::class, 'generateUrlFormat'])
  66. ->args([
  67. service('router'),
  68. '_profiler_open_file',
  69. '?file=%%f&line=%%l#line%%l',
  70. ])
  71. ;
  72. };