vendor/symfony/framework-bundle/DependencyInjection/FrameworkExtension.php line 299

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <[email protected]>
  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\Bundle\FrameworkBundle\DependencyInjection;
  11. use Doctrine\Common\Annotations\AnnotationRegistry;
  12. use Doctrine\Common\Annotations\Reader;
  13. use Http\Client\HttpClient;
  14. use Psr\Cache\CacheItemPoolInterface;
  15. use Psr\Container\ContainerInterface as PsrContainerInterface;
  16. use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;
  17. use Psr\Http\Client\ClientInterface;
  18. use Psr\Log\LoggerAwareInterface;
  19. use Symfony\Bridge\Monolog\Processor\DebugProcessor;
  20. use Symfony\Bridge\Twig\Extension\CsrfExtension;
  21. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  22. use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
  23. use Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher;
  24. use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
  25. use Symfony\Bundle\FullStack;
  26. use Symfony\Component\Asset\PackageInterface;
  27. use Symfony\Component\BrowserKit\AbstractBrowser;
  28. use Symfony\Component\Cache\Adapter\AdapterInterface;
  29. use Symfony\Component\Cache\Adapter\ArrayAdapter;
  30. use Symfony\Component\Cache\Adapter\ChainAdapter;
  31. use Symfony\Component\Cache\Adapter\TagAwareAdapter;
  32. use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
  33. use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
  34. use Symfony\Component\Cache\Marshaller\MarshallerInterface;
  35. use Symfony\Component\Cache\ResettableInterface;
  36. use Symfony\Component\Config\FileLocator;
  37. use Symfony\Component\Config\Loader\LoaderInterface;
  38. use Symfony\Component\Config\Resource\DirectoryResource;
  39. use Symfony\Component\Config\ResourceCheckerInterface;
  40. use Symfony\Component\Console\Application;
  41. use Symfony\Component\Console\Command\Command;
  42. use Symfony\Component\DependencyInjection\Alias;
  43. use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  44. use Symfony\Component\DependencyInjection\ChildDefinition;
  45. use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
  46. use Symfony\Component\DependencyInjection\ContainerBuilder;
  47. use Symfony\Component\DependencyInjection\ContainerInterface;
  48. use Symfony\Component\DependencyInjection\Definition;
  49. use Symfony\Component\DependencyInjection\EnvVarLoaderInterface;
  50. use Symfony\Component\DependencyInjection\EnvVarProcessorInterface;
  51. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  52. use Symfony\Component\DependencyInjection\Exception\LogicException;
  53. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  54. use Symfony\Component\DependencyInjection\Parameter;
  55. use Symfony\Component\DependencyInjection\Reference;
  56. use Symfony\Component\DependencyInjection\ServiceLocator;
  57. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  58. use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
  59. use Symfony\Component\Finder\Finder;
  60. use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
  61. use Symfony\Component\Form\FormTypeExtensionInterface;
  62. use Symfony\Component\Form\FormTypeGuesserInterface;
  63. use Symfony\Component\Form\FormTypeInterface;
  64. use Symfony\Component\HttpClient\ScopingHttpClient;
  65. use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
  66. use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
  67. use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
  68. use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
  69. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  70. use Symfony\Component\Lock\Factory;
  71. use Symfony\Component\Lock\Lock;
  72. use Symfony\Component\Lock\LockFactory;
  73. use Symfony\Component\Lock\LockInterface;
  74. use Symfony\Component\Lock\PersistingStoreInterface;
  75. use Symfony\Component\Lock\Store\StoreFactory;
  76. use Symfony\Component\Lock\StoreInterface;
  77. use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
  78. use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
  79. use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
  80. use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory;
  81. use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory;
  82. use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory;
  83. use Symfony\Component\Mailer\Mailer;
  84. use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
  85. use Symfony\Component\Messenger\MessageBus;
  86. use Symfony\Component\Messenger\MessageBusInterface;
  87. use Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory;
  88. use Symfony\Component\Messenger\Transport\RedisExt\RedisTransportFactory;
  89. use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
  90. use Symfony\Component\Messenger\Transport\TransportInterface;
  91. use Symfony\Component\Mime\MimeTypeGuesserInterface;
  92. use Symfony\Component\Mime\MimeTypes;
  93. use Symfony\Component\PropertyAccess\PropertyAccessor;
  94. use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
  95. use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface;
  96. use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
  97. use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface;
  98. use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
  99. use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
  100. use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
  101. use Symfony\Component\Routing\Generator\UrlGenerator;
  102. use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
  103. use Symfony\Component\Routing\Loader\AnnotationFileLoader;
  104. use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
  105. use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
  106. use Symfony\Component\Security\Core\Security;
  107. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  108. use Symfony\Component\Serializer\Encoder\DecoderInterface;
  109. use Symfony\Component\Serializer\Encoder\EncoderInterface;
  110. use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
  111. use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer;
  112. use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  113. use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  114. use Symfony\Component\Stopwatch\Stopwatch;
  115. use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
  116. use Symfony\Component\Translation\Translator;
  117. use Symfony\Component\Translation\TranslatorInterface;
  118. use Symfony\Component\Validator\ConstraintValidatorInterface;
  119. use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
  120. use Symfony\Component\Validator\ObjectInitializerInterface;
  121. use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
  122. use Symfony\Component\WebLink\HttpHeaderSerializer;
  123. use Symfony\Component\Workflow;
  124. use Symfony\Component\Workflow\WorkflowInterface;
  125. use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
  126. use Symfony\Component\Yaml\Yaml;
  127. use Symfony\Contracts\Cache\CacheInterface;
  128. use Symfony\Contracts\Cache\TagAwareCacheInterface;
  129. use Symfony\Contracts\HttpClient\HttpClientInterface;
  130. use Symfony\Contracts\Service\ResetInterface;
  131. use Symfony\Contracts\Service\ServiceSubscriberInterface;
  132. use Symfony\Contracts\Translation\LocaleAwareInterface;
  133. /**
  134.  * FrameworkExtension.
  135.  *
  136.  * @author Fabien Potencier <[email protected]>
  137.  * @author Jeremy Mikola <[email protected]>
  138.  * @author Kévin Dunglas <[email protected]>
  139.  * @author Grégoire Pineau <[email protected]>
  140.  */
  141. class FrameworkExtension extends Extension
  142. {
  143.     private $formConfigEnabled false;
  144.     private $translationConfigEnabled false;
  145.     private $sessionConfigEnabled false;
  146.     private $annotationsConfigEnabled false;
  147.     private $validatorConfigEnabled false;
  148.     private $messengerConfigEnabled false;
  149.     private $mailerConfigEnabled false;
  150.     private $httpClientConfigEnabled false;
  151.     /**
  152.      * Responds to the app.config configuration parameter.
  153.      *
  154.      * @throws LogicException
  155.      */
  156.     public function load(array $configsContainerBuilder $container)
  157.     {
  158.         $loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
  159.         $loader->load('web.xml');
  160.         $loader->load('services.xml');
  161.         $loader->load('fragment_renderer.xml');
  162.         $loader->load('error_renderer.xml');
  163.         if (interface_exists(PsrEventDispatcherInterface::class)) {
  164.             $container->setAlias(PsrEventDispatcherInterface::class, 'event_dispatcher');
  165.         }
  166.         $container->registerAliasForArgument('parameter_bag'PsrContainerInterface::class);
  167.         if (class_exists(Application::class)) {
  168.             $loader->load('console.xml');
  169.             if (!class_exists(BaseXliffLintCommand::class)) {
  170.                 $container->removeDefinition('console.command.xliff_lint');
  171.             }
  172.             if (!class_exists(BaseYamlLintCommand::class)) {
  173.                 $container->removeDefinition('console.command.yaml_lint');
  174.             }
  175.         }
  176.         // Load Cache configuration first as it is used by other components
  177.         $loader->load('cache.xml');
  178.         $configuration $this->getConfiguration($configs$container);
  179.         $config $this->processConfiguration($configuration$configs);
  180.         $this->annotationsConfigEnabled $this->isConfigEnabled($container$config['annotations']);
  181.         $this->translationConfigEnabled $this->isConfigEnabled($container$config['translator']);
  182.         // A translator must always be registered (as support is included by
  183.         // default in the Form and Validator component). If disabled, an identity
  184.         // translator will be used and everything will still work as expected.
  185.         if ($this->isConfigEnabled($container$config['translator']) || $this->isConfigEnabled($container$config['form']) || $this->isConfigEnabled($container$config['validation'])) {
  186.             if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container$config['translator'])) {
  187.                 throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
  188.             }
  189.             if (class_exists(Translator::class)) {
  190.                 $loader->load('identity_translator.xml');
  191.             }
  192.         }
  193.         if (isset($config['secret'])) {
  194.             $container->setParameter('kernel.secret'$config['secret']);
  195.         }
  196.         $container->setParameter('kernel.http_method_override'$config['http_method_override']);
  197.         $container->setParameter('kernel.trusted_hosts'$config['trusted_hosts']);
  198.         $container->setParameter('kernel.default_locale'$config['default_locale']);
  199.         $container->setParameter('kernel.error_controller'$config['error_controller']);
  200.         if (!$container->hasParameter('debug.file_link_format')) {
  201.             if (!$container->hasParameter('templating.helper.code.file_link_format')) {
  202.                 $links = [
  203.                     'textmate' => 'txmt://open?url=file://%%f&line=%%l',
  204.                     'macvim' => 'mvim://open?url=file://%%f&line=%%l',
  205.                     'emacs' => 'emacs://open?url=file://%%f&line=%%l',
  206.                     'sublime' => 'subl://open?url=file://%%f&line=%%l',
  207.                     'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
  208.                     'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
  209.                     'vscode' => 'vscode://file/%%f:%%l',
  210.                 ];
  211.                 $ide $config['ide'];
  212.                 // mark any env vars found in the ide setting as used
  213.                 $container->resolveEnvPlaceholders($ide);
  214.                 $container->setParameter('templating.helper.code.file_link_format'str_replace('%''%%'ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide));
  215.             }
  216.             $container->setParameter('debug.file_link_format''%templating.helper.code.file_link_format%');
  217.         }
  218.         if (!empty($config['test'])) {
  219.             $loader->load('test.xml');
  220.             if (!class_exists(AbstractBrowser::class)) {
  221.                 $container->removeDefinition('test.client');
  222.             }
  223.         }
  224.         // register cache before session so both can share the connection services
  225.         $this->registerCacheConfiguration($config['cache'], $container);
  226.         if ($this->isConfigEnabled($container$config['session'])) {
  227.             if (!\extension_loaded('session')) {
  228.                 throw new LogicException('Session support cannot be enabled as the session extension is not installed. See https://php.net/session.installation for instructions.');
  229.             }
  230.             $this->sessionConfigEnabled true;
  231.             $this->registerSessionConfiguration($config['session'], $container$loader);
  232.             if (!empty($config['test'])) {
  233.                 $container->getDefinition('test.session.listener')->setArgument(1'%session.storage.options%');
  234.             }
  235.         }
  236.         if ($this->isConfigEnabled($container$config['request'])) {
  237.             $this->registerRequestConfiguration($config['request'], $container$loader);
  238.         }
  239.         if (null === $config['csrf_protection']['enabled']) {
  240.             $config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class);
  241.         }
  242.         $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container$loader);
  243.         if ($this->isConfigEnabled($container$config['form'])) {
  244.             if (!class_exists('Symfony\Component\Form\Form')) {
  245.                 throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
  246.             }
  247.             $this->formConfigEnabled true;
  248.             $this->registerFormConfiguration($config$container$loader);
  249.             if (class_exists('Symfony\Component\Validator\Validation')) {
  250.                 $config['validation']['enabled'] = true;
  251.             } else {
  252.                 $container->setParameter('validator.translation_domain''validators');
  253.                 $container->removeDefinition('form.type_extension.form.validator');
  254.                 $container->removeDefinition('form.type_guesser.validator');
  255.             }
  256.         } else {
  257.             $container->removeDefinition('console.command.form_debug');
  258.         }
  259.         if ($this->isConfigEnabled($container$config['assets'])) {
  260.             if (!class_exists('Symfony\Component\Asset\Package')) {
  261.                 throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
  262.             }
  263.             $this->registerAssetsConfiguration($config['assets'], $container$loader);
  264.         }
  265.         if ($this->isConfigEnabled($container$config['templating'])) {
  266.             @trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.'E_USER_DEPRECATED);
  267.             if (!class_exists('Symfony\Component\Templating\PhpEngine')) {
  268.                 throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".');
  269.             }
  270.             $this->registerTemplatingConfiguration($config['templating'], $container$loader);
  271.         }
  272.         if ($this->messengerConfigEnabled $this->isConfigEnabled($container$config['messenger'])) {
  273.             $this->registerMessengerConfiguration($config['messenger'], $container$loader$config['validation']);
  274.         } else {
  275.             $container->removeDefinition('console.command.messenger_consume_messages');
  276.             $container->removeDefinition('console.command.messenger_debug');
  277.             $container->removeDefinition('console.command.messenger_stop_workers');
  278.             $container->removeDefinition('console.command.messenger_setup_transports');
  279.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  280.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  281.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  282.             $container->removeDefinition('cache.messenger.restart_workers_signal');
  283.             if ($container->hasDefinition('messenger.transport.amqp.factory') && class_exists(AmqpTransportFactory::class)) {
  284.                 $container->getDefinition('messenger.transport.amqp.factory')
  285.                     ->addTag('messenger.transport_factory');
  286.             }
  287.             if ($container->hasDefinition('messenger.transport.redis.factory') && class_exists(RedisTransportFactory::class)) {
  288.                 $container->getDefinition('messenger.transport.redis.factory')
  289.                     ->addTag('messenger.transport_factory');
  290.             }
  291.         }
  292.         if ($this->httpClientConfigEnabled $this->isConfigEnabled($container$config['http_client'])) {
  293.             $this->registerHttpClientConfiguration($config['http_client'], $container$loader$config['profiler']);
  294.         }
  295.         if ($this->mailerConfigEnabled $this->isConfigEnabled($container$config['mailer'])) {
  296.             $this->registerMailerConfiguration($config['mailer'], $container$loader);
  297.         }
  298.         $propertyInfoEnabled $this->isConfigEnabled($container$config['property_info']);
  299.         $this->registerValidationConfiguration($config['validation'], $container$loader$propertyInfoEnabled);
  300.         $this->registerEsiConfiguration($config['esi'], $container$loader);
  301.         $this->registerSsiConfiguration($config['ssi'], $container$loader);
  302.         $this->registerFragmentsConfiguration($config['fragments'], $container$loader);
  303.         $this->registerTranslatorConfiguration($config['translator'], $container$loader$config['default_locale']);
  304.         $this->registerProfilerConfiguration($config['profiler'], $container$loader);
  305.         $this->registerWorkflowConfiguration($config['workflows'], $container$loader);
  306.         $this->registerDebugConfiguration($config['php_errors'], $container$loader);
  307.         $this->registerRouterConfiguration($config['router'], $container$loader);
  308.         $this->registerAnnotationsConfiguration($config['annotations'], $container$loader);
  309.         $this->registerPropertyAccessConfiguration($config['property_access'], $container$loader);
  310.         $this->registerSecretsConfiguration($config['secrets'], $container$loader);
  311.         if ($this->isConfigEnabled($container$config['serializer'])) {
  312.             if (!class_exists('Symfony\Component\Serializer\Serializer')) {
  313.                 throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
  314.             }
  315.             $this->registerSerializerConfiguration($config['serializer'], $container$loader);
  316.         }
  317.         if ($propertyInfoEnabled) {
  318.             $this->registerPropertyInfoConfiguration($container$loader);
  319.         }
  320.         if ($this->isConfigEnabled($container$config['lock'])) {
  321.             $this->registerLockConfiguration($config['lock'], $container$loader);
  322.         }
  323.         if ($this->isConfigEnabled($container$config['web_link'])) {
  324.             if (!class_exists(HttpHeaderSerializer::class)) {
  325.                 throw new LogicException('WebLink support cannot be enabled as the WebLink component is not installed. Try running "composer require symfony/weblink".');
  326.             }
  327.             $loader->load('web_link.xml');
  328.         }
  329.         $this->addAnnotatedClassesToCompile([
  330.             '**\\Controller\\',
  331.             '**\\Entity\\',
  332.             // Added explicitly so that we don't rely on the class map being dumped to make it work
  333.             'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController',
  334.         ]);
  335.         if (class_exists(MimeTypes::class)) {
  336.             $loader->load('mime_type.xml');
  337.         }
  338.         $container->registerForAutoconfiguration(Command::class)
  339.             ->addTag('console.command');
  340.         $container->registerForAutoconfiguration(ResourceCheckerInterface::class)
  341.             ->addTag('config_cache.resource_checker');
  342.         $container->registerForAutoconfiguration(EnvVarLoaderInterface::class)
  343.             ->addTag('container.env_var_loader');
  344.         $container->registerForAutoconfiguration(EnvVarProcessorInterface::class)
  345.             ->addTag('container.env_var_processor');
  346.         $container->registerForAutoconfiguration(ServiceLocator::class)
  347.             ->addTag('container.service_locator');
  348.         $container->registerForAutoconfiguration(ServiceSubscriberInterface::class)
  349.             ->addTag('container.service_subscriber');
  350.         $container->registerForAutoconfiguration(ArgumentValueResolverInterface::class)
  351.             ->addTag('controller.argument_value_resolver');
  352.         $container->registerForAutoconfiguration(AbstractController::class)
  353.             ->addTag('controller.service_arguments');
  354.         $container->registerForAutoconfiguration('Symfony\Bundle\FrameworkBundle\Controller\Controller')
  355.             ->addTag('controller.service_arguments');
  356.         $container->registerForAutoconfiguration(DataCollectorInterface::class)
  357.             ->addTag('data_collector');
  358.         $container->registerForAutoconfiguration(FormTypeInterface::class)
  359.             ->addTag('form.type');
  360.         $container->registerForAutoconfiguration(FormTypeGuesserInterface::class)
  361.             ->addTag('form.type_guesser');
  362.         $container->registerForAutoconfiguration(FormTypeExtensionInterface::class)
  363.             ->addTag('form.type_extension');
  364.         $container->registerForAutoconfiguration(CacheClearerInterface::class)
  365.             ->addTag('kernel.cache_clearer');
  366.         $container->registerForAutoconfiguration(CacheWarmerInterface::class)
  367.             ->addTag('kernel.cache_warmer');
  368.         $container->registerForAutoconfiguration(EventSubscriberInterface::class)
  369.             ->addTag('kernel.event_subscriber');
  370.         $container->registerForAutoconfiguration(LocaleAwareInterface::class)
  371.             ->addTag('kernel.locale_aware');
  372.         $container->registerForAutoconfiguration(ResetInterface::class)
  373.             ->addTag('kernel.reset', ['method' => 'reset']);
  374.         if (!interface_exists(MarshallerInterface::class)) {
  375.             $container->registerForAutoconfiguration(ResettableInterface::class)
  376.                 ->addTag('kernel.reset', ['method' => 'reset']);
  377.         }
  378.         $container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
  379.             ->addTag('property_info.list_extractor');
  380.         $container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
  381.             ->addTag('property_info.type_extractor');
  382.         $container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class)
  383.             ->addTag('property_info.description_extractor');
  384.         $container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class)
  385.             ->addTag('property_info.access_extractor');
  386.         $container->registerForAutoconfiguration(PropertyInitializableExtractorInterface::class)
  387.             ->addTag('property_info.initializable_extractor');
  388.         $container->registerForAutoconfiguration(EncoderInterface::class)
  389.             ->addTag('serializer.encoder');
  390.         $container->registerForAutoconfiguration(DecoderInterface::class)
  391.             ->addTag('serializer.encoder');
  392.         $container->registerForAutoconfiguration(NormalizerInterface::class)
  393.             ->addTag('serializer.normalizer');
  394.         $container->registerForAutoconfiguration(DenormalizerInterface::class)
  395.             ->addTag('serializer.normalizer');
  396.         $container->registerForAutoconfiguration(ConstraintValidatorInterface::class)
  397.             ->addTag('validator.constraint_validator');
  398.         $container->registerForAutoconfiguration(ObjectInitializerInterface::class)
  399.             ->addTag('validator.initializer');
  400.         $container->registerForAutoconfiguration(MessageHandlerInterface::class)
  401.             ->addTag('messenger.message_handler');
  402.         $container->registerForAutoconfiguration(TransportFactoryInterface::class)
  403.             ->addTag('messenger.transport_factory');
  404.         $container->registerForAutoconfiguration(MimeTypeGuesserInterface::class)
  405.             ->addTag('mime.mime_type_guesser');
  406.         $container->registerForAutoconfiguration(LoggerAwareInterface::class)
  407.             ->addMethodCall('setLogger', [new Reference('logger')]);
  408.         if (!$container->getParameter('kernel.debug')) {
  409.             // remove tagged iterator argument for resource checkers
  410.             $container->getDefinition('config_cache_factory')->setArguments([]);
  411.         }
  412.         if (!$config['disallow_search_engine_index'] ?? false) {
  413.             $container->removeDefinition('disallow_search_engine_index_response_listener');
  414.         }
  415.         $container->registerForAutoconfiguration(RouteLoaderInterface::class)
  416.             ->addTag('routing.route_loader');
  417.     }
  418.     /**
  419.      * {@inheritdoc}
  420.      */
  421.     public function getConfiguration(array $configContainerBuilder $container)
  422.     {
  423.         return new Configuration($container->getParameter('kernel.debug'));
  424.     }
  425.     private function registerFormConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  426.     {
  427.         $loader->load('form.xml');
  428.         if (null === $config['form']['csrf_protection']['enabled']) {
  429.             $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
  430.         }
  431.         if ($this->isConfigEnabled($container$config['form']['csrf_protection'])) {
  432.             $loader->load('form_csrf.xml');
  433.             $container->setParameter('form.type_extension.csrf.enabled'true);
  434.             $container->setParameter('form.type_extension.csrf.field_name'$config['form']['csrf_protection']['field_name']);
  435.         } else {
  436.             $container->setParameter('form.type_extension.csrf.enabled'false);
  437.         }
  438.         if (!class_exists(Translator::class)) {
  439.             $container->removeDefinition('form.type_extension.upload.validator');
  440.         }
  441.         if (!method_exists(CachingFactoryDecorator::class, 'reset')) {
  442.             $container->getDefinition('form.choice_list_factory.cached')
  443.                 ->clearTag('kernel.reset')
  444.             ;
  445.         }
  446.     }
  447.     private function registerEsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  448.     {
  449.         if (!$this->isConfigEnabled($container$config)) {
  450.             $container->removeDefinition('fragment.renderer.esi');
  451.             return;
  452.         }
  453.         $loader->load('esi.xml');
  454.     }
  455.     private function registerSsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  456.     {
  457.         if (!$this->isConfigEnabled($container$config)) {
  458.             $container->removeDefinition('fragment.renderer.ssi');
  459.             return;
  460.         }
  461.         $loader->load('ssi.xml');
  462.     }
  463.     private function registerFragmentsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  464.     {
  465.         if (!$this->isConfigEnabled($container$config)) {
  466.             $container->removeDefinition('fragment.renderer.hinclude');
  467.             return;
  468.         }
  469.         if ($container->hasParameter('fragment.renderer.hinclude.global_template') && '' !== $container->getParameter('fragment.renderer.hinclude.global_template') && null !== $config['hinclude_default_template']) {
  470.             throw new \LogicException('You cannot set both "templating.hinclude_default_template" and "fragments.hinclude_default_template", please only use "fragments.hinclude_default_template".');
  471.         }
  472.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  473.         $loader->load('fragment_listener.xml');
  474.         $container->setParameter('fragment.path'$config['path']);
  475.     }
  476.     private function registerProfilerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  477.     {
  478.         if (!$this->isConfigEnabled($container$config)) {
  479.             // this is needed for the WebProfiler to work even if the profiler is disabled
  480.             $container->setParameter('data_collector.templates', []);
  481.             return;
  482.         }
  483.         $loader->load('profiling.xml');
  484.         $loader->load('collectors.xml');
  485.         $loader->load('cache_debug.xml');
  486.         if ($this->formConfigEnabled) {
  487.             $loader->load('form_debug.xml');
  488.         }
  489.         if ($this->validatorConfigEnabled) {
  490.             $loader->load('validator_debug.xml');
  491.         }
  492.         if ($this->translationConfigEnabled) {
  493.             $loader->load('translation_debug.xml');
  494.             $container->getDefinition('translator.data_collector')->setDecoratedService('translator');
  495.         }
  496.         if ($this->messengerConfigEnabled) {
  497.             $loader->load('messenger_debug.xml');
  498.         }
  499.         if ($this->mailerConfigEnabled) {
  500.             $loader->load('mailer_debug.xml');
  501.         }
  502.         if ($this->httpClientConfigEnabled) {
  503.             $loader->load('http_client_debug.xml');
  504.         }
  505.         $container->setParameter('profiler_listener.only_exceptions'$config['only_exceptions']);
  506.         $container->setParameter('profiler_listener.only_master_requests'$config['only_master_requests']);
  507.         // Choose storage class based on the DSN
  508.         list($class) = explode(':'$config['dsn'], 2);
  509.         if ('file' !== $class) {
  510.             throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.'$class));
  511.         }
  512.         $container->setParameter('profiler.storage.dsn'$config['dsn']);
  513.         $container->getDefinition('profiler')
  514.             ->addArgument($config['collect'])
  515.             ->addTag('kernel.reset', ['method' => 'reset']);
  516.     }
  517.     private function registerWorkflowConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  518.     {
  519.         if (!$config['enabled']) {
  520.             $container->removeDefinition('console.command.workflow_dump');
  521.             return;
  522.         }
  523.         if (!class_exists(Workflow\Workflow::class)) {
  524.             throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed. Try running "composer require symfony/workflow".');
  525.         }
  526.         $loader->load('workflow.xml');
  527.         $registryDefinition $container->getDefinition('workflow.registry');
  528.         foreach ($config['workflows'] as $name => $workflow) {
  529.             $type $workflow['type'];
  530.             $workflowId sprintf('%s.%s'$type$name);
  531.             // Process Metadata (workflow + places (transition is done in the "create transition" block))
  532.             $metadataStoreDefinition = new Definition(Workflow\Metadata\InMemoryMetadataStore::class, [[], [], null]);
  533.             if ($workflow['metadata']) {
  534.                 $metadataStoreDefinition->replaceArgument(0$workflow['metadata']);
  535.             }
  536.             $placesMetadata = [];
  537.             foreach ($workflow['places'] as $place) {
  538.                 if ($place['metadata']) {
  539.                     $placesMetadata[$place['name']] = $place['metadata'];
  540.                 }
  541.             }
  542.             if ($placesMetadata) {
  543.                 $metadataStoreDefinition->replaceArgument(1$placesMetadata);
  544.             }
  545.             // Create transitions
  546.             $transitions = [];
  547.             $guardsConfiguration = [];
  548.             $transitionsMetadataDefinition = new Definition(\SplObjectStorage::class);
  549.             // Global transition counter per workflow
  550.             $transitionCounter 0;
  551.             foreach ($workflow['transitions'] as $transition) {
  552.                 if ('workflow' === $type) {
  553.                     $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]);
  554.                     $transitionDefinition->setPublic(false);
  555.                     $transitionId sprintf('%s.transition.%s'$workflowId$transitionCounter++);
  556.                     $container->setDefinition($transitionId$transitionDefinition);
  557.                     $transitions[] = new Reference($transitionId);
  558.                     if (isset($transition['guard'])) {
  559.                         $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  560.                         $configuration->addArgument(new Reference($transitionId));
  561.                         $configuration->addArgument($transition['guard']);
  562.                         $configuration->setPublic(false);
  563.                         $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  564.                         $guardsConfiguration[$eventName][] = $configuration;
  565.                     }
  566.                     if ($transition['metadata']) {
  567.                         $transitionsMetadataDefinition->addMethodCall('attach', [
  568.                             new Reference($transitionId),
  569.                             $transition['metadata'],
  570.                         ]);
  571.                     }
  572.                 } elseif ('state_machine' === $type) {
  573.                     foreach ($transition['from'] as $from) {
  574.                         foreach ($transition['to'] as $to) {
  575.                             $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from$to]);
  576.                             $transitionDefinition->setPublic(false);
  577.                             $transitionId sprintf('%s.transition.%s'$workflowId$transitionCounter++);
  578.                             $container->setDefinition($transitionId$transitionDefinition);
  579.                             $transitions[] = new Reference($transitionId);
  580.                             if (isset($transition['guard'])) {
  581.                                 $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  582.                                 $configuration->addArgument(new Reference($transitionId));
  583.                                 $configuration->addArgument($transition['guard']);
  584.                                 $configuration->setPublic(false);
  585.                                 $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  586.                                 $guardsConfiguration[$eventName][] = $configuration;
  587.                             }
  588.                             if ($transition['metadata']) {
  589.                                 $transitionsMetadataDefinition->addMethodCall('attach', [
  590.                                     new Reference($transitionId),
  591.                                     $transition['metadata'],
  592.                                 ]);
  593.                             }
  594.                         }
  595.                     }
  596.                 }
  597.             }
  598.             $metadataStoreDefinition->replaceArgument(2$transitionsMetadataDefinition);
  599.             // Create places
  600.             $places array_column($workflow['places'], 'name');
  601.             $initialMarking $workflow['initial_marking'] ?? $workflow['initial_place'] ?? [];
  602.             // Create a Definition
  603.             $definitionDefinition = new Definition(Workflow\Definition::class);
  604.             $definitionDefinition->setPublic(false);
  605.             $definitionDefinition->addArgument($places);
  606.             $definitionDefinition->addArgument($transitions);
  607.             $definitionDefinition->addArgument($initialMarking);
  608.             $definitionDefinition->addArgument($metadataStoreDefinition);
  609.             $definitionDefinition->addTag('workflow.definition', [
  610.                 'name' => $name,
  611.                 'type' => $type,
  612.             ]);
  613.             // Create MarkingStore
  614.             if (isset($workflow['marking_store']['type'])) {
  615.                 $markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']);
  616.                 if ('method' === $workflow['marking_store']['type']) {
  617.                     $markingStoreDefinition->setArguments([
  618.                         'state_machine' === $type//single state
  619.                         $workflow['marking_store']['property'] ?? 'marking',
  620.                     ]);
  621.                 } else {
  622.                     foreach ($workflow['marking_store']['arguments'] as $argument) {
  623.                         $markingStoreDefinition->addArgument($argument);
  624.                     }
  625.                 }
  626.             } elseif (isset($workflow['marking_store']['service'])) {
  627.                 $markingStoreDefinition = new Reference($workflow['marking_store']['service']);
  628.             }
  629.             // Create Workflow
  630.             $workflowDefinition = new ChildDefinition(sprintf('%s.abstract'$type));
  631.             $workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition'$workflowId)));
  632.             if (isset($markingStoreDefinition)) {
  633.                 $workflowDefinition->replaceArgument(1$markingStoreDefinition);
  634.             }
  635.             $workflowDefinition->replaceArgument(3$name);
  636.             // Store to container
  637.             $container->setDefinition($workflowId$workflowDefinition);
  638.             $container->setDefinition(sprintf('%s.definition'$workflowId), $definitionDefinition);
  639.             $container->registerAliasForArgument($workflowIdWorkflowInterface::class, $name.'.'.$type);
  640.             // Validate Workflow
  641.             $validator null;
  642.             switch (true) {
  643.                 case 'state_machine' === $workflow['type']:
  644.                     $validator = new Workflow\Validator\StateMachineValidator();
  645.                     break;
  646.                 case 'single_state' === ($workflow['marking_store']['type'] ?? null):
  647.                     $validator = new Workflow\Validator\WorkflowValidator(true);
  648.                     break;
  649.                 case 'multiple_state' === ($workflow['marking_store']['type'] ?? false):
  650.                     $validator = new Workflow\Validator\WorkflowValidator(false);
  651.                     break;
  652.             }
  653.             if ($validator) {
  654.                 $trs array_map(function (Reference $ref) use ($container): Workflow\Transition {
  655.                     return $container->get((string) $ref);
  656.                 }, $transitions);
  657.                 $realDefinition = new Workflow\Definition($places$trs$initialMarking);
  658.                 $validator->validate($realDefinition$name);
  659.             }
  660.             // Add workflow to Registry
  661.             if ($workflow['supports']) {
  662.                 foreach ($workflow['supports'] as $supportedClassName) {
  663.                     $strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, [$supportedClassName]);
  664.                     $strategyDefinition->setPublic(false);
  665.                     $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
  666.                 }
  667.             } elseif (isset($workflow['support_strategy'])) {
  668.                 $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), new Reference($workflow['support_strategy'])]);
  669.             }
  670.             // Enable the AuditTrail
  671.             if ($workflow['audit_trail']['enabled']) {
  672.                 $listener = new Definition(Workflow\EventListener\AuditTrailListener::class);
  673.                 $listener->setPrivate(true);
  674.                 $listener->addTag('monolog.logger', ['channel' => 'workflow']);
  675.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave'$name), 'method' => 'onLeave']);
  676.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition'$name), 'method' => 'onTransition']);
  677.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter'$name), 'method' => 'onEnter']);
  678.                 $listener->addArgument(new Reference('logger'));
  679.                 $container->setDefinition(sprintf('%s.listener.audit_trail'$workflowId), $listener);
  680.             }
  681.             // Add Guard Listener
  682.             if ($guardsConfiguration) {
  683.                 if (!class_exists(ExpressionLanguage::class)) {
  684.                     throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
  685.                 }
  686.                 if (!class_exists(Security::class)) {
  687.                     throw new LogicException('Cannot guard workflows as the Security component is not installed. Try running "composer require symfony/security-core".');
  688.                 }
  689.                 $guard = new Definition(Workflow\EventListener\GuardListener::class);
  690.                 $guard->setPrivate(true);
  691.                 $guard->setArguments([
  692.                     $guardsConfiguration,
  693.                     new Reference('workflow.security.expression_language'),
  694.                     new Reference('security.token_storage'),
  695.                     new Reference('security.authorization_checker'),
  696.                     new Reference('security.authentication.trust_resolver'),
  697.                     new Reference('security.role_hierarchy'),
  698.                     new Reference('validator'ContainerInterface::NULL_ON_INVALID_REFERENCE),
  699.                 ]);
  700.                 foreach ($guardsConfiguration as $eventName => $config) {
  701.                     $guard->addTag('kernel.event_listener', ['event' => $eventName'method' => 'onTransition']);
  702.                 }
  703.                 $container->setDefinition(sprintf('%s.listener.guard'$workflowId), $guard);
  704.                 $container->setParameter('workflow.has_guard_listeners'true);
  705.             }
  706.         }
  707.     }
  708.     private function registerDebugConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  709.     {
  710.         $loader->load('debug_prod.xml');
  711.         if (class_exists(Stopwatch::class)) {
  712.             $container->register('debug.stopwatch'Stopwatch::class)
  713.                 ->addArgument(true)
  714.                 ->setPrivate(true)
  715.                 ->addTag('kernel.reset', ['method' => 'reset']);
  716.             $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch'false));
  717.         }
  718.         $debug $container->getParameter('kernel.debug');
  719.         if ($debug) {
  720.             $container->setParameter('debug.container.dump''%kernel.cache_dir%/%kernel.container_class%.xml');
  721.         }
  722.         if ($debug && class_exists(Stopwatch::class)) {
  723.             $loader->load('debug.xml');
  724.         }
  725.         $definition $container->findDefinition('debug.debug_handlers_listener');
  726.         if (false === $config['log']) {
  727.             $definition->replaceArgument(1null);
  728.         } elseif (true !== $config['log']) {
  729.             $definition->replaceArgument(2$config['log']);
  730.         }
  731.         if (!$config['throw']) {
  732.             $container->setParameter('debug.error_handler.throw_at'0);
  733.         }
  734.         if ($debug && class_exists(DebugProcessor::class)) {
  735.             $definition = new Definition(DebugProcessor::class);
  736.             $definition->setPublic(false);
  737.             $definition->addArgument(new Reference('request_stack'));
  738.             $container->setDefinition('debug.log_processor'$definition);
  739.         }
  740.     }
  741.     private function registerRouterConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  742.     {
  743.         if (!$this->isConfigEnabled($container$config)) {
  744.             $container->removeDefinition('console.command.router_debug');
  745.             $container->removeDefinition('console.command.router_match');
  746.             return;
  747.         }
  748.         $loader->load('routing.xml');
  749.         if ($config['utf8']) {
  750.             $container->getDefinition('routing.loader')->replaceArgument(2, ['utf8' => true]);
  751.         }
  752.         $container->setParameter('router.resource'$config['resource']);
  753.         $container->setParameter('router.cache_class_prefix'$container->getParameter('kernel.container_class')); // deprecated
  754.         $router $container->findDefinition('router.default');
  755.         $argument $router->getArgument(2);
  756.         $argument['strict_requirements'] = $config['strict_requirements'];
  757.         if (isset($config['type'])) {
  758.             $argument['resource_type'] = $config['type'];
  759.         }
  760.         if (!class_exists(CompiledUrlMatcher::class)) {
  761.             $argument['matcher_class'] = $argument['matcher_base_class'] = $argument['matcher_base_class'] ?? RedirectableUrlMatcher::class;
  762.             $argument['matcher_dumper_class'] = PhpMatcherDumper::class;
  763.             $argument['generator_class'] = $argument['generator_base_class'] = $argument['generator_base_class'] ?? UrlGenerator::class;
  764.             $argument['generator_dumper_class'] = PhpGeneratorDumper::class;
  765.         }
  766.         $router->replaceArgument(2$argument);
  767.         $container->setParameter('request_listener.http_port'$config['http_port']);
  768.         $container->setParameter('request_listener.https_port'$config['https_port']);
  769.         if ($this->annotationsConfigEnabled) {
  770.             $container->register('routing.loader.annotation'AnnotatedRouteControllerLoader::class)
  771.                 ->setPublic(false)
  772.                 ->addTag('routing.loader', ['priority' => -10])
  773.                 ->addArgument(new Reference('annotation_reader'));
  774.             $container->register('routing.loader.annotation.directory'AnnotationDirectoryLoader::class)
  775.                 ->setPublic(false)
  776.                 ->addTag('routing.loader', ['priority' => -10])
  777.                 ->setArguments([
  778.                     new Reference('file_locator'),
  779.                     new Reference('routing.loader.annotation'),
  780.                 ]);
  781.             $container->register('routing.loader.annotation.file'AnnotationFileLoader::class)
  782.                 ->setPublic(false)
  783.                 ->addTag('routing.loader', ['priority' => -10])
  784.                 ->setArguments([
  785.                     new Reference('file_locator'),
  786.                     new Reference('routing.loader.annotation'),
  787.                 ]);
  788.         }
  789.     }
  790.     private function registerSessionConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  791.     {
  792.         $loader->load('session.xml');
  793.         // session storage
  794.         $container->setAlias('session.storage'$config['storage_id'])->setPrivate(true);
  795.         $options = ['cache_limiter' => '0'];
  796.         foreach (['name''cookie_lifetime''cookie_path''cookie_domain''cookie_secure''cookie_httponly''cookie_samesite''use_cookies''gc_maxlifetime''gc_probability''gc_divisor''sid_length''sid_bits_per_character'] as $key) {
  797.             if (isset($config[$key])) {
  798.                 $options[$key] = $config[$key];
  799.             }
  800.         }
  801.         if ('auto' === ($options['cookie_secure'] ?? null)) {
  802.             $locator $container->getDefinition('session_listener')->getArgument(0);
  803.             $locator->setValues($locator->getValues() + [
  804.                 'session_storage' => new Reference('session.storage'ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
  805.                 'request_stack' => new Reference('request_stack'),
  806.             ]);
  807.         }
  808.         $container->setParameter('session.storage.options'$options);
  809.         // session handler (the internal callback registered with PHP session management)
  810.         if (null === $config['handler_id']) {
  811.             // Set the handler class to be null
  812.             $container->getDefinition('session.storage.native')->replaceArgument(1null);
  813.             $container->getDefinition('session.storage.php_bridge')->replaceArgument(0null);
  814.             $container->setAlias('session.handler''session.handler.native_file')->setPrivate(true);
  815.         } else {
  816.             $container->resolveEnvPlaceholders($config['handler_id'], null$usedEnvs);
  817.             if ($usedEnvs || preg_match('#^[a-z]++://#'$config['handler_id'])) {
  818.                 $id '.cache_connection.'.ContainerBuilder::hash($config['handler_id']);
  819.                 $container->getDefinition('session.abstract_handler')
  820.                     ->replaceArgument(0$container->hasDefinition($id) ? new Reference($id) : $config['handler_id']);
  821.                 $container->setAlias('session.handler''session.abstract_handler')->setPrivate(true);
  822.             } else {
  823.                 $container->setAlias('session.handler'$config['handler_id'])->setPrivate(true);
  824.             }
  825.         }
  826.         $container->setParameter('session.save_path'$config['save_path']);
  827.         $container->setParameter('session.metadata.update_threshold'$config['metadata_update_threshold']);
  828.     }
  829.     private function registerRequestConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  830.     {
  831.         if ($config['formats']) {
  832.             $loader->load('request.xml');
  833.             $listener $container->getDefinition('request.add_request_formats_listener');
  834.             $listener->replaceArgument(0$config['formats']);
  835.         }
  836.     }
  837.     private function registerTemplatingConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  838.     {
  839.         $loader->load('templating.xml');
  840.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  841.         if ($container->getParameter('kernel.debug')) {
  842.             $logger = new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE);
  843.             $container->getDefinition('templating.loader.cache')
  844.                 ->addTag('monolog.logger', ['channel' => 'templating'])
  845.                 ->addMethodCall('setLogger', [$logger]);
  846.             $container->getDefinition('templating.loader.chain')
  847.                 ->addTag('monolog.logger', ['channel' => 'templating'])
  848.                 ->addMethodCall('setLogger', [$logger]);
  849.         }
  850.         if (!empty($config['loaders'])) {
  851.             $loaders array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);
  852.             // Use a delegation unless only a single loader was registered
  853.             if (=== \count($loaders)) {
  854.                 $container->setAlias('templating.loader', (string) reset($loaders))->setPrivate(true);
  855.             } else {
  856.                 $container->getDefinition('templating.loader.chain')->addArgument($loaders);
  857.                 $container->setAlias('templating.loader''templating.loader.chain')->setPrivate(true);
  858.             }
  859.         }
  860.         $container->setParameter('templating.loader.cache.path'null);
  861.         if (isset($config['cache'])) {
  862.             // Wrap the existing loader with cache (must happen after loaders are registered)
  863.             $container->setDefinition('templating.loader.wrapped'$container->findDefinition('templating.loader'));
  864.             $loaderCache $container->getDefinition('templating.loader.cache');
  865.             $container->setParameter('templating.loader.cache.path'$config['cache']);
  866.             $container->setDefinition('templating.loader'$loaderCache);
  867.         }
  868.         $container->setParameter('templating.engines'$config['engines']);
  869.         $engines array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
  870.         // Use a delegation unless only a single engine was registered
  871.         if (=== \count($engines)) {
  872.             $container->setAlias('templating', (string) reset($engines))->setPublic(true);
  873.         } else {
  874.             $templateEngineDefinition $container->getDefinition('templating.engine.delegating');
  875.             foreach ($engines as $engine) {
  876.                 $templateEngineDefinition->addMethodCall('addEngine', [$engine]);
  877.             }
  878.             $container->setAlias('templating''templating.engine.delegating')->setPublic(true);
  879.         }
  880.         $container->getDefinition('fragment.renderer.hinclude')
  881.             ->addTag('kernel.fragment_renderer', ['alias' => 'hinclude'])
  882.             ->replaceArgument(0, new Reference('templating'))
  883.         ;
  884.         // configure the PHP engine if needed
  885.         if (\in_array('php'$config['engines'], true)) {
  886.             $loader->load('templating_php.xml');
  887.             $container->setParameter('templating.helper.form.resources'$config['form']['resources']);
  888.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  889.                 $loader->load('templating_debug.xml');
  890.                 $container->setDefinition('templating.engine.php'$container->findDefinition('debug.templating.engine.php'));
  891.                 $container->setAlias('debug.templating.engine.php''templating.engine.php')->setPrivate(true);
  892.             }
  893.             if ($container->has('assets.packages')) {
  894.                 $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages'));
  895.             } else {
  896.                 $container->removeDefinition('templating.helper.assets');
  897.             }
  898.         }
  899.     }
  900.     private function registerAssetsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  901.     {
  902.         $loader->load('assets.xml');
  903.         if ($config['version_strategy']) {
  904.             $defaultVersion = new Reference($config['version_strategy']);
  905.         } else {
  906.             $defaultVersion $this->createVersion($container$config['version'], $config['version_format'], $config['json_manifest_path'], '_default');
  907.         }
  908.         $defaultPackage $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
  909.         $container->setDefinition('assets._default_package'$defaultPackage);
  910.         $namedPackages = [];
  911.         foreach ($config['packages'] as $name => $package) {
  912.             if (null !== $package['version_strategy']) {
  913.                 $version = new Reference($package['version_strategy']);
  914.             } elseif (!\array_key_exists('version'$package) && null === $package['json_manifest_path']) {
  915.                 // if neither version nor json_manifest_path are specified, use the default
  916.                 $version $defaultVersion;
  917.             } else {
  918.                 // let format fallback to main version_format
  919.                 $format $package['version_format'] ?: $config['version_format'];
  920.                 $version = isset($package['version']) ? $package['version'] : null;
  921.                 $version $this->createVersion($container$version$format$package['json_manifest_path'], $name);
  922.             }
  923.             $container->setDefinition('assets._package_'.$name$this->createPackageDefinition($package['base_path'], $package['base_urls'], $version));
  924.             $container->registerAliasForArgument('assets._package_'.$namePackageInterface::class, $name.'.package');
  925.             $namedPackages[$name] = new Reference('assets._package_'.$name);
  926.         }
  927.         $container->getDefinition('assets.packages')
  928.             ->replaceArgument(0, new Reference('assets._default_package'))
  929.             ->replaceArgument(1$namedPackages)
  930.         ;
  931.     }
  932.     /**
  933.      * Returns a definition for an asset package.
  934.      */
  935.     private function createPackageDefinition(?string $basePath, array $baseUrlsReference $version): Definition
  936.     {
  937.         if ($basePath && $baseUrls) {
  938.             throw new \LogicException('An asset package cannot have base URLs and base paths.');
  939.         }
  940.         $package = new ChildDefinition($baseUrls 'assets.url_package' 'assets.path_package');
  941.         $package
  942.             ->setPublic(false)
  943.             ->replaceArgument(0$baseUrls ?: $basePath)
  944.             ->replaceArgument(1$version)
  945.         ;
  946.         return $package;
  947.     }
  948.     private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPathstring $name): Reference
  949.     {
  950.         // Configuration prevents $version and $jsonManifestPath from being set
  951.         if (null !== $version) {
  952.             $def = new ChildDefinition('assets.static_version_strategy');
  953.             $def
  954.                 ->replaceArgument(0$version)
  955.                 ->replaceArgument(1$format)
  956.             ;
  957.             $container->setDefinition('assets._version_'.$name$def);
  958.             return new Reference('assets._version_'.$name);
  959.         }
  960.         if (null !== $jsonManifestPath) {
  961.             $def = new ChildDefinition('assets.json_manifest_version_strategy');
  962.             $def->replaceArgument(0$jsonManifestPath);
  963.             $container->setDefinition('assets._version_'.$name$def);
  964.             return new Reference('assets._version_'.$name);
  965.         }
  966.         return new Reference('assets.empty_version_strategy');
  967.     }
  968.     private function registerTranslatorConfiguration(array $configContainerBuilder $containerLoaderInterface $loaderstring $defaultLocale)
  969.     {
  970.         if (!$this->isConfigEnabled($container$config)) {
  971.             $container->removeDefinition('console.command.translation_debug');
  972.             $container->removeDefinition('console.command.translation_update');
  973.             return;
  974.         }
  975.         $loader->load('translation.xml');
  976.         // Use the "real" translator instead of the identity default
  977.         $container->setAlias('translator''translator.default')->setPublic(true);
  978.         $container->setAlias('translator.formatter', new Alias($config['formatter'], false));
  979.         $translator $container->findDefinition('translator.default');
  980.         $translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
  981.         $defaultOptions $translator->getArgument(4);
  982.         $defaultOptions['cache_dir'] = $config['cache_dir'];
  983.         $translator->setArgument(4$defaultOptions);
  984.         $container->setParameter('translator.logging'$config['logging']);
  985.         $container->setParameter('translator.default_path'$config['default_path']);
  986.         // Discover translation directories
  987.         $dirs = [];
  988.         $transPaths = [];
  989.         $nonExistingDirs = [];
  990.         if (class_exists('Symfony\Component\Validator\Validation')) {
  991.             $r = new \ReflectionClass('Symfony\Component\Validator\Validation');
  992.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  993.         }
  994.         if (class_exists('Symfony\Component\Form\Form')) {
  995.             $r = new \ReflectionClass('Symfony\Component\Form\Form');
  996.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  997.         }
  998.         if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
  999.             $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
  1000.             $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
  1001.         }
  1002.         $defaultDir $container->getParameterBag()->resolveValue($config['default_path']);
  1003.         $rootDir $container->getParameter('kernel.root_dir');
  1004.         foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
  1005.             if ($container->fileExists($dir $bundle['path'].'/Resources/translations') || $container->fileExists($dir $bundle['path'].'/translations')) {
  1006.                 $dirs[] = $dir;
  1007.             } else {
  1008.                 $nonExistingDirs[] = $dir;
  1009.             }
  1010.             if ($container->fileExists($dir $rootDir.sprintf('/Resources/%s/translations'$name))) {
  1011.                 @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.'$dir$defaultDir), E_USER_DEPRECATED);
  1012.                 $dirs[] = $dir;
  1013.             } else {
  1014.                 $nonExistingDirs[] = $dir;
  1015.             }
  1016.         }
  1017.         foreach ($config['paths'] as $dir) {
  1018.             if ($container->fileExists($dir)) {
  1019.                 $dirs[] = $transPaths[] = $dir;
  1020.             } else {
  1021.                 throw new \UnexpectedValueException(sprintf('"%s" defined in translator.paths does not exist or is not a directory.'$dir));
  1022.             }
  1023.         }
  1024.         if ($container->hasDefinition('console.command.translation_debug')) {
  1025.             $container->getDefinition('console.command.translation_debug')->replaceArgument(5$transPaths);
  1026.         }
  1027.         if ($container->hasDefinition('console.command.translation_update')) {
  1028.             $container->getDefinition('console.command.translation_update')->replaceArgument(6$transPaths);
  1029.         }
  1030.         if ($container->fileExists($defaultDir)) {
  1031.             $dirs[] = $defaultDir;
  1032.         } else {
  1033.             $nonExistingDirs[] = $defaultDir;
  1034.         }
  1035.         if ($container->fileExists($dir $rootDir.'/Resources/translations')) {
  1036.             if ($dir !== $defaultDir) {
  1037.                 @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.'$dir$defaultDir), E_USER_DEPRECATED);
  1038.             }
  1039.             $dirs[] = $dir;
  1040.         } else {
  1041.             $nonExistingDirs[] = $dir;
  1042.         }
  1043.         // Register translation resources
  1044.         if ($dirs) {
  1045.             $files = [];
  1046.             $finder Finder::create()
  1047.                 ->followLinks()
  1048.                 ->files()
  1049.                 ->filter(function (\SplFileInfo $file) {
  1050.                     return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  1051.                 })
  1052.                 ->in($dirs)
  1053.                 ->sortByName()
  1054.             ;
  1055.             foreach ($finder as $file) {
  1056.                 $fileNameParts explode('.'basename($file));
  1057.                 $locale $fileNameParts[\count($fileNameParts) - 2];
  1058.                 if (!isset($files[$locale])) {
  1059.                     $files[$locale] = [];
  1060.                 }
  1061.                 $files[$locale][] = (string) $file;
  1062.             }
  1063.             $projectDir $container->getParameter('kernel.project_dir');
  1064.             $options array_merge(
  1065.                 $translator->getArgument(4),
  1066.                 [
  1067.                     'resource_files' => $files,
  1068.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1069.                     'cache_vary' => [
  1070.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1071.                             return === strpos($dir$projectDir.'/') ? substr($dir+ \strlen($projectDir)) : $dir;
  1072.                         }, $scannedDirectories),
  1073.                     ],
  1074.                 ]
  1075.             );
  1076.             $translator->replaceArgument(4$options);
  1077.         }
  1078.     }
  1079.     private function registerValidationConfiguration(array $configContainerBuilder $containerXmlFileLoader $loaderbool $propertyInfoEnabled)
  1080.     {
  1081.         if (!$this->validatorConfigEnabled $this->isConfigEnabled($container$config)) {
  1082.             return;
  1083.         }
  1084.         if (!class_exists('Symfony\Component\Validator\Validation')) {
  1085.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1086.         }
  1087.         if (!isset($config['email_validation_mode'])) {
  1088.             $config['email_validation_mode'] = 'loose';
  1089.         }
  1090.         $loader->load('validator.xml');
  1091.         $validatorBuilder $container->getDefinition('validator.builder');
  1092.         if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
  1093.             $calls $validatorBuilder->getMethodCalls();
  1094.             $calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])]];
  1095.             $validatorBuilder->setMethodCalls($calls);
  1096.         }
  1097.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1098.         $files = ['xml' => [], 'yml' => []];
  1099.         $this->registerValidatorMapping($container$config$files);
  1100.         if (!empty($files['xml'])) {
  1101.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1102.         }
  1103.         if (!empty($files['yml'])) {
  1104.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1105.         }
  1106.         $definition $container->findDefinition('validator.email');
  1107.         $definition->replaceArgument(0$config['email_validation_mode']);
  1108.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1109.             if (!$this->annotationsConfigEnabled) {
  1110.                 throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
  1111.             }
  1112.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
  1113.         }
  1114.         if (\array_key_exists('static_method'$config) && $config['static_method']) {
  1115.             foreach ($config['static_method'] as $methodName) {
  1116.                 $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
  1117.             }
  1118.         }
  1119.         if (!$container->getParameter('kernel.debug')) {
  1120.             $validatorBuilder->addMethodCall('setMappingCache', [new Reference('validator.mapping.cache.adapter')]);
  1121.         }
  1122.         $container->setParameter('validator.auto_mapping'$config['auto_mapping']);
  1123.         if (!$propertyInfoEnabled || !class_exists(PropertyInfoLoader::class)) {
  1124.             $container->removeDefinition('validator.property_info_loader');
  1125.         }
  1126.         $container
  1127.             ->getDefinition('validator.not_compromised_password')
  1128.             ->setArgument(2$config['not_compromised_password']['enabled'])
  1129.             ->setArgument(3$config['not_compromised_password']['endpoint'])
  1130.         ;
  1131.     }
  1132.     private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files)
  1133.     {
  1134.         $fileRecorder = function ($extension$path) use (&$files) {
  1135.             $files['yaml' === $extension 'yml' $extension][] = $path;
  1136.         };
  1137.         if (interface_exists('Symfony\Component\Form\FormInterface')) {
  1138.             $reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
  1139.             $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
  1140.         }
  1141.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1142.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1143.             if (
  1144.                 $container->fileExists($file $configDir.'/validation.yaml'false) ||
  1145.                 $container->fileExists($file $configDir.'/validation.yml'false)
  1146.             ) {
  1147.                 $fileRecorder('yml'$file);
  1148.             }
  1149.             if ($container->fileExists($file $configDir.'/validation.xml'false)) {
  1150.                 $fileRecorder('xml'$file);
  1151.             }
  1152.             if ($container->fileExists($dir $configDir.'/validation''/^$/')) {
  1153.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1154.             }
  1155.         }
  1156.         $projectDir $container->getParameter('kernel.project_dir');
  1157.         if ($container->fileExists($dir $projectDir.'/config/validator''/^$/')) {
  1158.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1159.         }
  1160.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1161.     }
  1162.     private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
  1163.     {
  1164.         foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
  1165.             $fileRecorder($file->getExtension(), $file->getRealPath());
  1166.         }
  1167.     }
  1168.     private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder)
  1169.     {
  1170.         foreach ($config['mapping']['paths'] as $path) {
  1171.             if (is_dir($path)) {
  1172.                 $this->registerMappingFilesFromDir($path$fileRecorder);
  1173.                 $container->addResource(new DirectoryResource($path'/^$/'));
  1174.             } elseif ($container->fileExists($pathfalse)) {
  1175.                 if (!preg_match('/\.(xml|ya?ml)$/'$path$matches)) {
  1176.                     throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.'$path));
  1177.                 }
  1178.                 $fileRecorder($matches[1], $path);
  1179.             } else {
  1180.                 throw new \RuntimeException(sprintf('Could not open file or directory "%s".'$path));
  1181.             }
  1182.         }
  1183.     }
  1184.     private function registerAnnotationsConfiguration(array $configContainerBuilder $containerLoaderInterface $loader)
  1185.     {
  1186.         if (!$this->annotationsConfigEnabled) {
  1187.             return;
  1188.         }
  1189.         if (!class_exists('Doctrine\Common\Annotations\Annotation')) {
  1190.             throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
  1191.         }
  1192.         $loader->load('annotations.xml');
  1193.         if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  1194.             $container->getDefinition('annotations.dummy_registry')
  1195.                 ->setMethodCalls([['registerLoader', ['class_exists']]]);
  1196.         }
  1197.         if ('none' !== $config['cache']) {
  1198.             if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {
  1199.                 throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
  1200.             }
  1201.             $cacheService $config['cache'];
  1202.             if ('php_array' === $config['cache']) {
  1203.                 $cacheService 'annotations.cache';
  1204.                 // Enable warmer only if PHP array is used for cache
  1205.                 $definition $container->findDefinition('annotations.cache_warmer');
  1206.                 $definition->addTag('kernel.cache_warmer');
  1207.             } elseif ('file' === $config['cache']) {
  1208.                 $cacheDir $container->getParameterBag()->resolveValue($config['file_cache_dir']);
  1209.                 if (!is_dir($cacheDir) && false === @mkdir($cacheDir0777true) && !is_dir($cacheDir)) {
  1210.                     throw new \RuntimeException(sprintf('Could not create cache directory "%s".'$cacheDir));
  1211.                 }
  1212.                 $container
  1213.                     ->getDefinition('annotations.filesystem_cache')
  1214.                     ->replaceArgument(0$cacheDir)
  1215.                 ;
  1216.                 $cacheService 'annotations.filesystem_cache';
  1217.             }
  1218.             $container
  1219.                 ->getDefinition('annotations.cached_reader')
  1220.                 ->replaceArgument(2$config['debug'])
  1221.                 // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
  1222.                 ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
  1223.                 ->addTag('annotations.cached_reader')
  1224.             ;
  1225.             $container->setAlias('annotation_reader''annotations.cached_reader')->setPrivate(true);
  1226.             $container->setAlias(Reader::class, new Alias('annotations.cached_reader'false));
  1227.         } else {
  1228.             $container->removeDefinition('annotations.cached_reader');
  1229.         }
  1230.     }
  1231.     private function registerPropertyAccessConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1232.     {
  1233.         if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
  1234.             return;
  1235.         }
  1236.         $loader->load('property_access.xml');
  1237.         $container
  1238.             ->getDefinition('property_accessor')
  1239.             ->replaceArgument(0$config['magic_call'])
  1240.             ->replaceArgument(1$config['throw_exception_on_invalid_index'])
  1241.             ->replaceArgument(3$config['throw_exception_on_invalid_property_path'])
  1242.         ;
  1243.     }
  1244.     private function registerSecretsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1245.     {
  1246.         if (!$this->isConfigEnabled($container$config)) {
  1247.             $container->removeDefinition('console.command.secrets_set');
  1248.             $container->removeDefinition('console.command.secrets_list');
  1249.             $container->removeDefinition('console.command.secrets_remove');
  1250.             $container->removeDefinition('console.command.secrets_generate_key');
  1251.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1252.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1253.             return;
  1254.         }
  1255.         $loader->load('secrets.xml');
  1256.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1257.         if ($config['local_dotenv_file']) {
  1258.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1259.         } else {
  1260.             $container->removeDefinition('secrets.local_vault');
  1261.         }
  1262.         if ($config['decryption_env_var']) {
  1263.             if (!preg_match('/^(?:\w*+:)*+\w++$/'$config['decryption_env_var'])) {
  1264.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1265.             }
  1266.             $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1267.         } else {
  1268.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1269.         }
  1270.     }
  1271.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1272.     {
  1273.         if (!$this->isConfigEnabled($container$config)) {
  1274.             return;
  1275.         }
  1276.         if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) {
  1277.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1278.         }
  1279.         if (!$this->sessionConfigEnabled) {
  1280.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1281.         }
  1282.         // Enable services for CSRF protection (even without forms)
  1283.         $loader->load('security_csrf.xml');
  1284.         if (!class_exists(CsrfExtension::class)) {
  1285.             $container->removeDefinition('twig.extension.security_csrf');
  1286.         }
  1287.     }
  1288.     private function registerSerializerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1289.     {
  1290.         $loader->load('serializer.xml');
  1291.         if (!class_exists(ConstraintViolationListNormalizer::class)) {
  1292.             $container->removeDefinition('serializer.normalizer.constraint_violation_list');
  1293.         }
  1294.         if (!class_exists(ClassDiscriminatorFromClassMetadata::class)) {
  1295.             $container->removeAlias('Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface');
  1296.             $container->removeDefinition('serializer.mapping.class_discriminator_resolver');
  1297.         }
  1298.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1299.         if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
  1300.             $container->removeAlias('serializer.property_accessor');
  1301.             $container->removeDefinition('serializer.normalizer.object');
  1302.         }
  1303.         if (!class_exists(Yaml::class)) {
  1304.             $container->removeDefinition('serializer.encoder.yaml');
  1305.         }
  1306.         $serializerLoaders = [];
  1307.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1308.             if (!$this->annotationsConfigEnabled) {
  1309.                 throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
  1310.             }
  1311.             $annotationLoader = new Definition(
  1312.                 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
  1313.                 [new Reference('annotation_reader')]
  1314.             );
  1315.             $annotationLoader->setPublic(false);
  1316.             $serializerLoaders[] = $annotationLoader;
  1317.         }
  1318.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1319.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
  1320.             $definition->setPublic(false);
  1321.             $serializerLoaders[] = $definition;
  1322.         };
  1323.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1324.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1325.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1326.                 $fileRecorder('xml'$file);
  1327.             }
  1328.             if (
  1329.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1330.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1331.             ) {
  1332.                 $fileRecorder('yml'$file);
  1333.             }
  1334.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1335.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1336.             }
  1337.         }
  1338.         $projectDir $container->getParameter('kernel.project_dir');
  1339.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1340.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1341.         }
  1342.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1343.         $chainLoader->replaceArgument(0$serializerLoaders);
  1344.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1345.         if ($container->getParameter('kernel.debug')) {
  1346.             $container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
  1347.         }
  1348.         if (isset($config['name_converter']) && $config['name_converter']) {
  1349.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1350.         }
  1351.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1352.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1353.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1354.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1355.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1356.         }
  1357.         if ($config['max_depth_handler'] ?? false) {
  1358.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1359.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1360.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1361.         }
  1362.     }
  1363.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerXmlFileLoader $loader)
  1364.     {
  1365.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1366.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1367.         }
  1368.         $loader->load('property_info.xml');
  1369.         if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) {
  1370.             $definition $container->register('property_info.php_doc_extractor''Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
  1371.             $definition->setPrivate(true);
  1372.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1373.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1374.         }
  1375.         if ($container->getParameter('kernel.debug')) {
  1376.             $container->removeDefinition('property_info.cache');
  1377.         }
  1378.     }
  1379.     private function registerLockConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1380.     {
  1381.         $loader->load('lock.xml');
  1382.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1383.             if (=== \count($resourceStores)) {
  1384.                 continue;
  1385.             }
  1386.             // Generate stores
  1387.             $storeDefinitions = [];
  1388.             foreach ($resourceStores as $storeDsn) {
  1389.                 $storeDsn $container->resolveEnvPlaceholders($storeDsnnull$usedEnvs);
  1390.                 $storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class);
  1391.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1392.                 $storeDefinition->setArguments([$storeDsn]);
  1393.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1394.                 $storeDefinition = new Reference($storeDefinitionId);
  1395.                 $storeDefinitions[] = $storeDefinition;
  1396.             }
  1397.             // Wrap array of stores with CombinedStore
  1398.             if (\count($storeDefinitions) > 1) {
  1399.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1400.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1401.                 $container->setDefinition('lock.'.$resourceName.'.store'$combinedDefinition);
  1402.             } else {
  1403.                 $container->setAlias('lock.'.$resourceName.'.store', new Alias((string) $storeDefinitions[0], false));
  1404.             }
  1405.             // Generate factories for each resource
  1406.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1407.             $factoryDefinition->replaceArgument(0, new Reference('lock.'.$resourceName.'.store'));
  1408.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1409.             // Generate services for lock instances
  1410.             $lockDefinition = new Definition(Lock::class);
  1411.             $lockDefinition->setPublic(false);
  1412.             $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
  1413.             $lockDefinition->setArguments([$resourceName]);
  1414.             $container->setDefinition('lock.'.$resourceName$lockDefinition);
  1415.             // provide alias for default resource
  1416.             if ('default' === $resourceName) {
  1417.                 $container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store'false));
  1418.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1419.                 $container->setAlias('lock', new Alias('lock.'.$resourceNamefalse));
  1420.                 $container->setAlias(StoreInterface::class, new Alias('lock.store'false));
  1421.                 $container->setAlias(PersistingStoreInterface::class, new Alias('lock.store'false));
  1422.                 $container->setAlias(Factory::class, new Alias('lock.factory'false));
  1423.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1424.                 $container->setAlias(LockInterface::class, new Alias('lock'false));
  1425.             } else {
  1426.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'StoreInterface::class, $resourceName.'.lock.store');
  1427.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'PersistingStoreInterface::class, $resourceName.'.lock.store');
  1428.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'Factory::class, $resourceName.'.lock.factory');
  1429.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1430.                 $container->registerAliasForArgument('lock.'.$resourceNameLockInterface::class, $resourceName.'.lock');
  1431.             }
  1432.         }
  1433.     }
  1434.     private function registerMessengerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $validationConfig)
  1435.     {
  1436.         if (!interface_exists(MessageBusInterface::class)) {
  1437.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1438.         }
  1439.         $loader->load('messenger.xml');
  1440.         if (class_exists(AmqpTransportFactory::class)) {
  1441.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1442.         }
  1443.         if (class_exists(RedisTransportFactory::class)) {
  1444.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1445.         }
  1446.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1447.             $config['default_bus'] = key($config['buses']);
  1448.         }
  1449.         $defaultMiddleware = [
  1450.             'before' => [
  1451.                 ['id' => 'add_bus_name_stamp_middleware'],
  1452.                 ['id' => 'reject_redelivered_message_middleware'],
  1453.                 ['id' => 'dispatch_after_current_bus'],
  1454.                 ['id' => 'failed_message_processing_middleware'],
  1455.             ],
  1456.             'after' => [
  1457.                 ['id' => 'send_message'],
  1458.                 ['id' => 'handle_message'],
  1459.             ],
  1460.         ];
  1461.         foreach ($config['buses'] as $busId => $bus) {
  1462.             $middleware $bus['middleware'];
  1463.             if ($bus['default_middleware']) {
  1464.                 if ('allow_no_handlers' === $bus['default_middleware']) {
  1465.                     $defaultMiddleware['after'][1]['arguments'] = [true];
  1466.                 } else {
  1467.                     unset($defaultMiddleware['after'][1]['arguments']);
  1468.                 }
  1469.                 // argument to add_bus_name_stamp_middleware
  1470.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1471.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1472.             }
  1473.             foreach ($middleware as $middlewareItem) {
  1474.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1475.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1476.                 }
  1477.             }
  1478.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1479.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1480.             }
  1481.             $container->setParameter($busId.'.middleware'$middleware);
  1482.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1483.             if ($busId === $config['default_bus']) {
  1484.                 $container->setAlias('message_bus'$busId)->setPublic(true)->setDeprecated(true'The "%alias_id%" service is deprecated, use the "messenger.default_bus" service instead.');
  1485.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1486.                 $container->setAlias(MessageBusInterface::class, $busId);
  1487.             } else {
  1488.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1489.             }
  1490.         }
  1491.         if (empty($config['transports'])) {
  1492.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1493.             $container->removeDefinition('messenger.transport.amqp.factory');
  1494.             $container->removeDefinition('messenger.transport.redis.factory');
  1495.         } else {
  1496.             $container->getDefinition('messenger.transport.symfony_serializer')
  1497.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1498.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1499.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1500.         }
  1501.         $senderAliases = [];
  1502.         $transportRetryReferences = [];
  1503.         foreach ($config['transports'] as $name => $transport) {
  1504.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1505.             $transportDefinition = (new Definition(TransportInterface::class))
  1506.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1507.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1508.                 ->addTag('messenger.receiver', ['alias' => $name])
  1509.             ;
  1510.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1511.             $senderAliases[$name] = $transportId;
  1512.             if (null !== $transport['retry_strategy']['service']) {
  1513.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1514.             } else {
  1515.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1516.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1517.                 $retryDefinition
  1518.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1519.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1520.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1521.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1522.                 $container->setDefinition($retryServiceId$retryDefinition);
  1523.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1524.             }
  1525.         }
  1526.         $senderReferences = [];
  1527.         // alias => service_id
  1528.         foreach ($senderAliases as $alias => $serviceId) {
  1529.             $senderReferences[$alias] = new Reference($serviceId);
  1530.         }
  1531.         // service_id => service_id
  1532.         foreach ($senderAliases as $serviceId) {
  1533.             $senderReferences[$serviceId] = new Reference($serviceId);
  1534.         }
  1535.         $messageToSendersMapping = [];
  1536.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1537.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1538.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1539.             }
  1540.             // make sure senderAliases contains all senders
  1541.             foreach ($messageConfiguration['senders'] as $sender) {
  1542.                 if (!isset($senderReferences[$sender])) {
  1543.                     throw new LogicException(sprintf('Invalid Messenger routing configuration: the "%s" class is being routed to a sender called "%s". This is not a valid transport or service id.'$message$sender));
  1544.                 }
  1545.             }
  1546.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1547.         }
  1548.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1549.         $container->getDefinition('messenger.senders_locator')
  1550.             ->replaceArgument(0$messageToSendersMapping)
  1551.             ->replaceArgument(1$sendersServiceLocator)
  1552.         ;
  1553.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1554.             ->replaceArgument(0$sendersServiceLocator)
  1555.         ;
  1556.         $container->getDefinition('messenger.retry_strategy_locator')
  1557.             ->replaceArgument(0$transportRetryReferences);
  1558.         if ($config['failure_transport']) {
  1559.             if (!isset($senderReferences[$config['failure_transport']])) {
  1560.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1561.             }
  1562.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1563.                 ->replaceArgument(0$senderReferences[$config['failure_transport']]);
  1564.             $container->getDefinition('console.command.messenger_failed_messages_retry')
  1565.                 ->replaceArgument(0$config['failure_transport']);
  1566.             $container->getDefinition('console.command.messenger_failed_messages_show')
  1567.                 ->replaceArgument(0$config['failure_transport']);
  1568.             $container->getDefinition('console.command.messenger_failed_messages_remove')
  1569.                 ->replaceArgument(0$config['failure_transport']);
  1570.         } else {
  1571.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1572.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1573.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1574.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1575.         }
  1576.     }
  1577.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1578.     {
  1579.         if (!class_exists(DefaultMarshaller::class)) {
  1580.             $container->removeDefinition('cache.default_marshaller');
  1581.         }
  1582.         $version = new Parameter('container.build_id');
  1583.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1584.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1585.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1586.         if (isset($config['prefix_seed'])) {
  1587.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1588.         }
  1589.         if ($container->hasParameter('cache.prefix.seed')) {
  1590.             // Inline any env vars referenced in the parameter
  1591.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1592.         }
  1593.         foreach (['doctrine''psr6''redis''memcached''pdo'] as $name) {
  1594.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1595.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1596.             }
  1597.         }
  1598.         foreach (['app''system'] as $name) {
  1599.             $config['pools']['cache.'.$name] = [
  1600.                 'adapters' => [$config[$name]],
  1601.                 'public' => true,
  1602.                 'tags' => false,
  1603.             ];
  1604.         }
  1605.         foreach ($config['pools'] as $name => $pool) {
  1606.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1607.             foreach ($pool['adapters'] as $provider => $adapter) {
  1608.                 if ($config['pools'][$adapter]['tags'] ?? false) {
  1609.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1610.                 }
  1611.             }
  1612.             if (=== \count($pool['adapters'])) {
  1613.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1614.                     $pool['provider'] = $provider;
  1615.                 }
  1616.                 $definition = new ChildDefinition($adapter);
  1617.             } else {
  1618.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1619.                 $pool['reset'] = 'reset';
  1620.             }
  1621.             if ($pool['tags']) {
  1622.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1623.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1624.                 }
  1625.                 $container->register($nameTagAwareAdapter::class)
  1626.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1627.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1628.                     ->setPublic($pool['public'])
  1629.                 ;
  1630.                 $pool['name'] = $name;
  1631.                 $pool['public'] = false;
  1632.                 $name '.'.$name.'.inner';
  1633.                 if (!\in_array($pool['name'], ['cache.app''cache.system'], true)) {
  1634.                     $container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
  1635.                     $container->registerAliasForArgument($nameCacheInterface::class, $pool['name']);
  1636.                     $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name']);
  1637.                 }
  1638.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1639.                 $container->register('.'.$name.'.taggable'TagAwareAdapter::class)
  1640.                     ->addArgument(new Reference($name))
  1641.                 ;
  1642.                 $container->registerAliasForArgument('.'.$name.'.taggable'TagAwareCacheInterface::class, $name);
  1643.                 $container->registerAliasForArgument($nameCacheInterface::class);
  1644.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class);
  1645.             }
  1646.             $definition->setPublic($pool['public']);
  1647.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1648.             $definition->addTag('cache.pool'$pool);
  1649.             $container->setDefinition($name$definition);
  1650.         }
  1651.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1652.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1653.             $propertyAccessDefinition->setPublic(false);
  1654.             if (!$container->getParameter('kernel.debug')) {
  1655.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1656.                 $propertyAccessDefinition->setArguments([null0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1657.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1658.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1659.             } else {
  1660.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1661.                 $propertyAccessDefinition->setArguments([0false]);
  1662.             }
  1663.         }
  1664.     }
  1665.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $profilerConfig)
  1666.     {
  1667.         $loader->load('http_client.xml');
  1668.         $container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
  1669.         if (!$hasPsr18 interface_exists(ClientInterface::class)) {
  1670.             $container->removeDefinition('psr18.http_client');
  1671.             $container->removeAlias(ClientInterface::class);
  1672.         }
  1673.         if (!interface_exists(HttpClient::class)) {
  1674.             $container->removeDefinition(HttpClient::class);
  1675.         }
  1676.         $httpClientId $this->isConfigEnabled($container$profilerConfig) ? '.debug.http_client.inner' 'http_client';
  1677.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1678.             if ('http_client' === $name) {
  1679.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1680.             }
  1681.             $scope $scopeConfig['scope'] ?? null;
  1682.             unset($scopeConfig['scope']);
  1683.             if (null === $scope) {
  1684.                 $container->register($nameScopingHttpClient::class)
  1685.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1686.                     ->setArguments([new Reference($httpClientId), $scopeConfig['base_uri'], $scopeConfig])
  1687.                     ->addTag('http_client.client')
  1688.                 ;
  1689.             } else {
  1690.                 $container->register($nameScopingHttpClient::class)
  1691.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1692.                     ->addTag('http_client.client')
  1693.                 ;
  1694.             }
  1695.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  1696.             if ($hasPsr18) {
  1697.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  1698.                     ->replaceArgument(0, new Reference($name));
  1699.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  1700.             }
  1701.         }
  1702.     }
  1703.     private function registerMailerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1704.     {
  1705.         if (!class_exists(Mailer::class)) {
  1706.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  1707.         }
  1708.         $loader->load('mailer.xml');
  1709.         $loader->load('mailer_transports.xml');
  1710.         if (!\count($config['transports']) && null === $config['dsn']) {
  1711.             $config['dsn'] = 'smtp://null';
  1712.         }
  1713.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  1714.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  1715.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  1716.         $classToServices = [
  1717.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  1718.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  1719.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  1720.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  1721.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  1722.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  1723.         ];
  1724.         foreach ($classToServices as $class => $service) {
  1725.             if (!class_exists($class)) {
  1726.                 $container->removeDefinition($service);
  1727.             }
  1728.         }
  1729.         $recipients $config['envelope']['recipients'] ?? null;
  1730.         $sender $config['envelope']['sender'] ?? null;
  1731.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  1732.         $envelopeListener->setArgument(0$sender);
  1733.         $envelopeListener->setArgument(1$recipients);
  1734.     }
  1735.     /**
  1736.      * {@inheritdoc}
  1737.      */
  1738.     public function getXsdValidationBasePath()
  1739.     {
  1740.         return \dirname(__DIR__).'/Resources/config/schema';
  1741.     }
  1742.     public function getNamespace()
  1743.     {
  1744.         return 'http://symfony.com/schema/dic/symfony';
  1745.     }
  1746. }