web.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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\Controller\ControllerResolver;
  12. use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
  13. use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver;
  14. use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver;
  15. use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestValueResolver;
  16. use Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver;
  17. use Symfony\Component\HttpKernel\Controller\ArgumentResolver\SessionValueResolver;
  18. use Symfony\Component\HttpKernel\Controller\ArgumentResolver\VariadicValueResolver;
  19. use Symfony\Component\HttpKernel\Controller\ErrorController;
  20. use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory;
  21. use Symfony\Component\HttpKernel\EventListener\DisallowRobotsIndexingListener;
  22. use Symfony\Component\HttpKernel\EventListener\ErrorListener;
  23. use Symfony\Component\HttpKernel\EventListener\LocaleListener;
  24. use Symfony\Component\HttpKernel\EventListener\ResponseListener;
  25. use Symfony\Component\HttpKernel\EventListener\StreamedResponseListener;
  26. use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener;
  27. return static function (ContainerConfigurator $container) {
  28. $container->services()
  29. ->set('controller_resolver', ControllerResolver::class)
  30. ->args([
  31. service('service_container'),
  32. service('logger')->ignoreOnInvalid(),
  33. ])
  34. ->tag('monolog.logger', ['channel' => 'request'])
  35. ->set('argument_metadata_factory', ArgumentMetadataFactory::class)
  36. ->set('argument_resolver', ArgumentResolver::class)
  37. ->args([
  38. service('argument_metadata_factory'),
  39. abstract_arg('argument value resolvers'),
  40. ])
  41. ->set('argument_resolver.request_attribute', RequestAttributeValueResolver::class)
  42. ->tag('controller.argument_value_resolver', ['priority' => 100])
  43. ->set('argument_resolver.request', RequestValueResolver::class)
  44. ->tag('controller.argument_value_resolver', ['priority' => 50])
  45. ->set('argument_resolver.session', SessionValueResolver::class)
  46. ->tag('controller.argument_value_resolver', ['priority' => 50])
  47. ->set('argument_resolver.service', ServiceValueResolver::class)
  48. ->args([
  49. abstract_arg('service locator, set in RegisterControllerArgumentLocatorsPass'),
  50. ])
  51. ->tag('controller.argument_value_resolver', ['priority' => -50])
  52. ->set('argument_resolver.default', DefaultValueResolver::class)
  53. ->tag('controller.argument_value_resolver', ['priority' => -100])
  54. ->set('argument_resolver.variadic', VariadicValueResolver::class)
  55. ->tag('controller.argument_value_resolver', ['priority' => -150])
  56. ->set('response_listener', ResponseListener::class)
  57. ->args([
  58. param('kernel.charset'),
  59. ])
  60. ->tag('kernel.event_subscriber')
  61. ->set('streamed_response_listener', StreamedResponseListener::class)
  62. ->tag('kernel.event_subscriber')
  63. ->set('locale_listener', LocaleListener::class)
  64. ->args([
  65. service('request_stack'),
  66. param('kernel.default_locale'),
  67. service('router')->ignoreOnInvalid(),
  68. ])
  69. ->tag('kernel.event_subscriber')
  70. ->set('validate_request_listener', ValidateRequestListener::class)
  71. ->tag('kernel.event_subscriber')
  72. ->set('disallow_search_engine_index_response_listener', DisallowRobotsIndexingListener::class)
  73. ->tag('kernel.event_subscriber')
  74. ->set('error_controller', ErrorController::class)
  75. ->public()
  76. ->args([
  77. service('http_kernel'),
  78. param('kernel.error_controller'),
  79. service('error_renderer'),
  80. ])
  81. ->set('exception_listener', ErrorListener::class)
  82. ->args([
  83. param('kernel.error_controller'),
  84. service('logger')->nullOnInvalid(),
  85. param('kernel.debug'),
  86. ])
  87. ->tag('kernel.event_subscriber')
  88. ->tag('monolog.logger', ['channel' => 'request'])
  89. ;
  90. };