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 <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\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 <fabien@symfony.com>
  137.  * @author Jeremy Mikola <jmikola@gmail.com>
  138.  * @author Kévin Dunglas <dunglas@gmail.com>
  139.  * @author Grégoire Pineau <lyrixx@lyrixx.info>
  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.         } else {
  815.             $container->resolveEnvPlaceholders($config['handler_id'], null$usedEnvs);
  816.             if ($usedEnvs || preg_match('#^[a-z]++://#'$config['handler_id'])) {
  817.                 $id '.cache_connection.'.ContainerBuilder::hash($config['handler_id']);
  818.                 $container->getDefinition('session.abstract_handler')
  819.                     ->replaceArgument(0$container->hasDefinition($id) ? new Reference($id) : $config['handler_id']);
  820.                 $container->setAlias('session.handler''session.abstract_handler')->setPrivate(true);
  821.             } else {
  822.                 $container->setAlias('session.handler'$config['handler_id'])->setPrivate(true);
  823.             }
  824.         }
  825.         $container->setParameter('session.save_path'$config['save_path']);
  826.         $container->setParameter('session.metadata.update_threshold'$config['metadata_update_threshold']);
  827.     }
  828.     private function registerRequestConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  829.     {
  830.         if ($config['formats']) {
  831.             $loader->load('request.xml');
  832.             $listener $container->getDefinition('request.add_request_formats_listener');
  833.             $listener->replaceArgument(0$config['formats']);
  834.         }
  835.     }
  836.     private function registerTemplatingConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  837.     {
  838.         $loader->load('templating.xml');
  839.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  840.         if ($container->getParameter('kernel.debug')) {
  841.             $logger = new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE);
  842.             $container->getDefinition('templating.loader.cache')
  843.                 ->addTag('monolog.logger', ['channel' => 'templating'])
  844.                 ->addMethodCall('setLogger', [$logger]);
  845.             $container->getDefinition('templating.loader.chain')
  846.                 ->addTag('monolog.logger', ['channel' => 'templating'])
  847.                 ->addMethodCall('setLogger', [$logger]);
  848.         }
  849.         if (!empty($config['loaders'])) {
  850.             $loaders array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);
  851.             // Use a delegation unless only a single loader was registered
  852.             if (=== \count($loaders)) {
  853.                 $container->setAlias('templating.loader', (string) reset($loaders))->setPrivate(true);
  854.             } else {
  855.                 $container->getDefinition('templating.loader.chain')->addArgument($loaders);
  856.                 $container->setAlias('templating.loader''templating.loader.chain')->setPrivate(true);
  857.             }
  858.         }
  859.         $container->setParameter('templating.loader.cache.path'null);
  860.         if (isset($config['cache'])) {
  861.             // Wrap the existing loader with cache (must happen after loaders are registered)
  862.             $container->setDefinition('templating.loader.wrapped'$container->findDefinition('templating.loader'));
  863.             $loaderCache $container->getDefinition('templating.loader.cache');
  864.             $container->setParameter('templating.loader.cache.path'$config['cache']);
  865.             $container->setDefinition('templating.loader'$loaderCache);
  866.         }
  867.         $container->setParameter('templating.engines'$config['engines']);
  868.         $engines array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
  869.         // Use a delegation unless only a single engine was registered
  870.         if (=== \count($engines)) {
  871.             $container->setAlias('templating', (string) reset($engines))->setPublic(true);
  872.         } else {
  873.             $templateEngineDefinition $container->getDefinition('templating.engine.delegating');
  874.             foreach ($engines as $engine) {
  875.                 $templateEngineDefinition->addMethodCall('addEngine', [$engine]);
  876.             }
  877.             $container->setAlias('templating''templating.engine.delegating')->setPublic(true);
  878.         }
  879.         $container->getDefinition('fragment.renderer.hinclude')
  880.             ->addTag('kernel.fragment_renderer', ['alias' => 'hinclude'])
  881.             ->replaceArgument(0, new Reference('templating'))
  882.         ;
  883.         // configure the PHP engine if needed
  884.         if (\in_array('php'$config['engines'], true)) {
  885.             $loader->load('templating_php.xml');
  886.             $container->setParameter('templating.helper.form.resources'$config['form']['resources']);
  887.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  888.                 $loader->load('templating_debug.xml');
  889.                 $container->setDefinition('templating.engine.php'$container->findDefinition('debug.templating.engine.php'));
  890.                 $container->setAlias('debug.templating.engine.php''templating.engine.php')->setPrivate(true);
  891.             }
  892.             if ($container->has('assets.packages')) {
  893.                 $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages'));
  894.             } else {
  895.                 $container->removeDefinition('templating.helper.assets');
  896.             }
  897.         }
  898.     }
  899.     private function registerAssetsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  900.     {
  901.         $loader->load('assets.xml');
  902.         if ($config['version_strategy']) {
  903.             $defaultVersion = new Reference($config['version_strategy']);
  904.         } else {
  905.             $defaultVersion $this->createVersion($container$config['version'], $config['version_format'], $config['json_manifest_path'], '_default');
  906.         }
  907.         $defaultPackage $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
  908.         $container->setDefinition('assets._default_package'$defaultPackage);
  909.         $namedPackages = [];
  910.         foreach ($config['packages'] as $name => $package) {
  911.             if (null !== $package['version_strategy']) {
  912.                 $version = new Reference($package['version_strategy']);
  913.             } elseif (!\array_key_exists('version'$package) && null === $package['json_manifest_path']) {
  914.                 // if neither version nor json_manifest_path are specified, use the default
  915.                 $version $defaultVersion;
  916.             } else {
  917.                 // let format fallback to main version_format
  918.                 $format $package['version_format'] ?: $config['version_format'];
  919.                 $version = isset($package['version']) ? $package['version'] : null;
  920.                 $version $this->createVersion($container$version$format$package['json_manifest_path'], $name);
  921.             }
  922.             $container->setDefinition('assets._package_'.$name$this->createPackageDefinition($package['base_path'], $package['base_urls'], $version));
  923.             $container->registerAliasForArgument('assets._package_'.$namePackageInterface::class, $name.'.package');
  924.             $namedPackages[$name] = new Reference('assets._package_'.$name);
  925.         }
  926.         $container->getDefinition('assets.packages')
  927.             ->replaceArgument(0, new Reference('assets._default_package'))
  928.             ->replaceArgument(1$namedPackages)
  929.         ;
  930.     }
  931.     /**
  932.      * Returns a definition for an asset package.
  933.      */
  934.     private function createPackageDefinition(?string $basePath, array $baseUrlsReference $version): Definition
  935.     {
  936.         if ($basePath && $baseUrls) {
  937.             throw new \LogicException('An asset package cannot have base URLs and base paths.');
  938.         }
  939.         $package = new ChildDefinition($baseUrls 'assets.url_package' 'assets.path_package');
  940.         $package
  941.             ->setPublic(false)
  942.             ->replaceArgument(0$baseUrls ?: $basePath)
  943.             ->replaceArgument(1$version)
  944.         ;
  945.         return $package;
  946.     }
  947.     private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPathstring $name): Reference
  948.     {
  949.         // Configuration prevents $version and $jsonManifestPath from being set
  950.         if (null !== $version) {
  951.             $def = new ChildDefinition('assets.static_version_strategy');
  952.             $def
  953.                 ->replaceArgument(0$version)
  954.                 ->replaceArgument(1$format)
  955.             ;
  956.             $container->setDefinition('assets._version_'.$name$def);
  957.             return new Reference('assets._version_'.$name);
  958.         }
  959.         if (null !== $jsonManifestPath) {
  960.             $def = new ChildDefinition('assets.json_manifest_version_strategy');
  961.             $def->replaceArgument(0$jsonManifestPath);
  962.             $container->setDefinition('assets._version_'.$name$def);
  963.             return new Reference('assets._version_'.$name);
  964.         }
  965.         return new Reference('assets.empty_version_strategy');
  966.     }
  967.     private function registerTranslatorConfiguration(array $configContainerBuilder $containerLoaderInterface $loaderstring $defaultLocale)
  968.     {
  969.         if (!$this->isConfigEnabled($container$config)) {
  970.             $container->removeDefinition('console.command.translation_debug');
  971.             $container->removeDefinition('console.command.translation_update');
  972.             return;
  973.         }
  974.         $loader->load('translation.xml');
  975.         // Use the "real" translator instead of the identity default
  976.         $container->setAlias('translator''translator.default')->setPublic(true);
  977.         $container->setAlias('translator.formatter', new Alias($config['formatter'], false));
  978.         $translator $container->findDefinition('translator.default');
  979.         $translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
  980.         $defaultOptions $translator->getArgument(4);
  981.         $defaultOptions['cache_dir'] = $config['cache_dir'];
  982.         $translator->setArgument(4$defaultOptions);
  983.         $container->setParameter('translator.logging'$config['logging']);
  984.         $container->setParameter('translator.default_path'$config['default_path']);
  985.         // Discover translation directories
  986.         $dirs = [];
  987.         $transPaths = [];
  988.         $nonExistingDirs = [];
  989.         if (class_exists('Symfony\Component\Validator\Validation')) {
  990.             $r = new \ReflectionClass('Symfony\Component\Validator\Validation');
  991.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  992.         }
  993.         if (class_exists('Symfony\Component\Form\Form')) {
  994.             $r = new \ReflectionClass('Symfony\Component\Form\Form');
  995.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  996.         }
  997.         if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
  998.             $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
  999.             $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
  1000.         }
  1001.         $defaultDir $container->getParameterBag()->resolveValue($config['default_path']);
  1002.         $rootDir $container->getParameter('kernel.root_dir');
  1003.         foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
  1004.             if ($container->fileExists($dir $bundle['path'].'/Resources/translations') || $container->fileExists($dir $bundle['path'].'/translations')) {
  1005.                 $dirs[] = $dir;
  1006.             } else {
  1007.                 $nonExistingDirs[] = $dir;
  1008.             }
  1009.             if ($container->fileExists($dir $rootDir.sprintf('/Resources/%s/translations'$name))) {
  1010.                 @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.'$dir$defaultDir), E_USER_DEPRECATED);
  1011.                 $dirs[] = $dir;
  1012.             } else {
  1013.                 $nonExistingDirs[] = $dir;
  1014.             }
  1015.         }
  1016.         foreach ($config['paths'] as $dir) {
  1017.             if ($container->fileExists($dir)) {
  1018.                 $dirs[] = $transPaths[] = $dir;
  1019.             } else {
  1020.                 throw new \UnexpectedValueException(sprintf('"%s" defined in translator.paths does not exist or is not a directory.'$dir));
  1021.             }
  1022.         }
  1023.         if ($container->hasDefinition('console.command.translation_debug')) {
  1024.             $container->getDefinition('console.command.translation_debug')->replaceArgument(5$transPaths);
  1025.         }
  1026.         if ($container->hasDefinition('console.command.translation_update')) {
  1027.             $container->getDefinition('console.command.translation_update')->replaceArgument(6$transPaths);
  1028.         }
  1029.         if ($container->fileExists($defaultDir)) {
  1030.             $dirs[] = $defaultDir;
  1031.         } else {
  1032.             $nonExistingDirs[] = $defaultDir;
  1033.         }
  1034.         if ($container->fileExists($dir $rootDir.'/Resources/translations')) {
  1035.             if ($dir !== $defaultDir) {
  1036.                 @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.'$dir$defaultDir), E_USER_DEPRECATED);
  1037.             }
  1038.             $dirs[] = $dir;
  1039.         } else {
  1040.             $nonExistingDirs[] = $dir;
  1041.         }
  1042.         // Register translation resources
  1043.         if ($dirs) {
  1044.             $files = [];
  1045.             $finder Finder::create()
  1046.                 ->followLinks()
  1047.                 ->files()
  1048.                 ->filter(function (\SplFileInfo $file) {
  1049.                     return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  1050.                 })
  1051.                 ->in($dirs)
  1052.                 ->sortByName()
  1053.             ;
  1054.             foreach ($finder as $file) {
  1055.                 $fileNameParts explode('.'basename($file));
  1056.                 $locale $fileNameParts[\count($fileNameParts) - 2];
  1057.                 if (!isset($files[$locale])) {
  1058.                     $files[$locale] = [];
  1059.                 }
  1060.                 $files[$locale][] = (string) $file;
  1061.             }
  1062.             $projectDir $container->getParameter('kernel.project_dir');
  1063.             $options array_merge(
  1064.                 $translator->getArgument(4),
  1065.                 [
  1066.                     'resource_files' => $files,
  1067.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1068.                     'cache_vary' => [
  1069.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1070.                             return === strpos($dir$projectDir.'/') ? substr($dir+ \strlen($projectDir)) : $dir;
  1071.                         }, $scannedDirectories),
  1072.                     ],
  1073.                 ]
  1074.             );
  1075.             $translator->replaceArgument(4$options);
  1076.         }
  1077.     }
  1078.     private function registerValidationConfiguration(array $configContainerBuilder $containerXmlFileLoader $loaderbool $propertyInfoEnabled)
  1079.     {
  1080.         if (!$this->validatorConfigEnabled $this->isConfigEnabled($container$config)) {
  1081.             return;
  1082.         }
  1083.         if (!class_exists('Symfony\Component\Validator\Validation')) {
  1084.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1085.         }
  1086.         if (!isset($config['email_validation_mode'])) {
  1087.             $config['email_validation_mode'] = 'loose';
  1088.         }
  1089.         $loader->load('validator.xml');
  1090.         $validatorBuilder $container->getDefinition('validator.builder');
  1091.         if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
  1092.             $calls $validatorBuilder->getMethodCalls();
  1093.             $calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])]];
  1094.             $validatorBuilder->setMethodCalls($calls);
  1095.         }
  1096.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1097.         $files = ['xml' => [], 'yml' => []];
  1098.         $this->registerValidatorMapping($container$config$files);
  1099.         if (!empty($files['xml'])) {
  1100.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1101.         }
  1102.         if (!empty($files['yml'])) {
  1103.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1104.         }
  1105.         $definition $container->findDefinition('validator.email');
  1106.         $definition->replaceArgument(0$config['email_validation_mode']);
  1107.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1108.             if (!$this->annotationsConfigEnabled) {
  1109.                 throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
  1110.             }
  1111.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
  1112.         }
  1113.         if (\array_key_exists('static_method'$config) && $config['static_method']) {
  1114.             foreach ($config['static_method'] as $methodName) {
  1115.                 $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
  1116.             }
  1117.         }
  1118.         if (!$container->getParameter('kernel.debug')) {
  1119.             $validatorBuilder->addMethodCall('setMappingCache', [new Reference('validator.mapping.cache.adapter')]);
  1120.         }
  1121.         $container->setParameter('validator.auto_mapping'$config['auto_mapping']);
  1122.         if (!$propertyInfoEnabled || !class_exists(PropertyInfoLoader::class)) {
  1123.             $container->removeDefinition('validator.property_info_loader');
  1124.         }
  1125.         $container
  1126.             ->getDefinition('validator.not_compromised_password')
  1127.             ->setArgument(2$config['not_compromised_password']['enabled'])
  1128.             ->setArgument(3$config['not_compromised_password']['endpoint'])
  1129.         ;
  1130.     }
  1131.     private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files)
  1132.     {
  1133.         $fileRecorder = function ($extension$path) use (&$files) {
  1134.             $files['yaml' === $extension 'yml' $extension][] = $path;
  1135.         };
  1136.         if (interface_exists('Symfony\Component\Form\FormInterface')) {
  1137.             $reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
  1138.             $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
  1139.         }
  1140.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1141.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1142.             if (
  1143.                 $container->fileExists($file $configDir.'/validation.yaml'false) ||
  1144.                 $container->fileExists($file $configDir.'/validation.yml'false)
  1145.             ) {
  1146.                 $fileRecorder('yml'$file);
  1147.             }
  1148.             if ($container->fileExists($file $configDir.'/validation.xml'false)) {
  1149.                 $fileRecorder('xml'$file);
  1150.             }
  1151.             if ($container->fileExists($dir $configDir.'/validation''/^$/')) {
  1152.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1153.             }
  1154.         }
  1155.         $projectDir $container->getParameter('kernel.project_dir');
  1156.         if ($container->fileExists($dir $projectDir.'/config/validator''/^$/')) {
  1157.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1158.         }
  1159.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1160.     }
  1161.     private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
  1162.     {
  1163.         foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
  1164.             $fileRecorder($file->getExtension(), $file->getRealPath());
  1165.         }
  1166.     }
  1167.     private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder)
  1168.     {
  1169.         foreach ($config['mapping']['paths'] as $path) {
  1170.             if (is_dir($path)) {
  1171.                 $this->registerMappingFilesFromDir($path$fileRecorder);
  1172.                 $container->addResource(new DirectoryResource($path'/^$/'));
  1173.             } elseif ($container->fileExists($pathfalse)) {
  1174.                 if (!preg_match('/\.(xml|ya?ml)$/'$path$matches)) {
  1175.                     throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.'$path));
  1176.                 }
  1177.                 $fileRecorder($matches[1], $path);
  1178.             } else {
  1179.                 throw new \RuntimeException(sprintf('Could not open file or directory "%s".'$path));
  1180.             }
  1181.         }
  1182.     }
  1183.     private function registerAnnotationsConfiguration(array $configContainerBuilder $containerLoaderInterface $loader)
  1184.     {
  1185.         if (!$this->annotationsConfigEnabled) {
  1186.             return;
  1187.         }
  1188.         if (!class_exists('Doctrine\Common\Annotations\Annotation')) {
  1189.             throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
  1190.         }
  1191.         $loader->load('annotations.xml');
  1192.         if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  1193.             $container->getDefinition('annotations.dummy_registry')
  1194.                 ->setMethodCalls([['registerLoader', ['class_exists']]]);
  1195.         }
  1196.         if ('none' !== $config['cache']) {
  1197.             if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {
  1198.                 throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
  1199.             }
  1200.             $cacheService $config['cache'];
  1201.             if ('php_array' === $config['cache']) {
  1202.                 $cacheService 'annotations.cache';
  1203.                 // Enable warmer only if PHP array is used for cache
  1204.                 $definition $container->findDefinition('annotations.cache_warmer');
  1205.                 $definition->addTag('kernel.cache_warmer');
  1206.             } elseif ('file' === $config['cache']) {
  1207.                 $cacheDir $container->getParameterBag()->resolveValue($config['file_cache_dir']);
  1208.                 if (!is_dir($cacheDir) && false === @mkdir($cacheDir0777true) && !is_dir($cacheDir)) {
  1209.                     throw new \RuntimeException(sprintf('Could not create cache directory "%s".'$cacheDir));
  1210.                 }
  1211.                 $container
  1212.                     ->getDefinition('annotations.filesystem_cache')
  1213.                     ->replaceArgument(0$cacheDir)
  1214.                 ;
  1215.                 $cacheService 'annotations.filesystem_cache';
  1216.             }
  1217.             $container
  1218.                 ->getDefinition('annotations.cached_reader')
  1219.                 ->replaceArgument(2$config['debug'])
  1220.                 // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
  1221.                 ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
  1222.                 ->addTag('annotations.cached_reader')
  1223.             ;
  1224.             $container->setAlias('annotation_reader''annotations.cached_reader')->setPrivate(true);
  1225.             $container->setAlias(Reader::class, new Alias('annotations.cached_reader'false));
  1226.         } else {
  1227.             $container->removeDefinition('annotations.cached_reader');
  1228.         }
  1229.     }
  1230.     private function registerPropertyAccessConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1231.     {
  1232.         if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
  1233.             return;
  1234.         }
  1235.         $loader->load('property_access.xml');
  1236.         $container
  1237.             ->getDefinition('property_accessor')
  1238.             ->replaceArgument(0$config['magic_call'])
  1239.             ->replaceArgument(1$config['throw_exception_on_invalid_index'])
  1240.             ->replaceArgument(3$config['throw_exception_on_invalid_property_path'])
  1241.         ;
  1242.     }
  1243.     private function registerSecretsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1244.     {
  1245.         if (!$this->isConfigEnabled($container$config)) {
  1246.             $container->removeDefinition('console.command.secrets_set');
  1247.             $container->removeDefinition('console.command.secrets_list');
  1248.             $container->removeDefinition('console.command.secrets_remove');
  1249.             $container->removeDefinition('console.command.secrets_generate_key');
  1250.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1251.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1252.             return;
  1253.         }
  1254.         $loader->load('secrets.xml');
  1255.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1256.         if ($config['local_dotenv_file']) {
  1257.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1258.         } else {
  1259.             $container->removeDefinition('secrets.local_vault');
  1260.         }
  1261.         if ($config['decryption_env_var']) {
  1262.             if (!preg_match('/^(?:\w*+:)*+\w++$/'$config['decryption_env_var'])) {
  1263.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1264.             }
  1265.             $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1266.         } else {
  1267.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1268.         }
  1269.     }
  1270.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1271.     {
  1272.         if (!$this->isConfigEnabled($container$config)) {
  1273.             return;
  1274.         }
  1275.         if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) {
  1276.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1277.         }
  1278.         if (!$this->sessionConfigEnabled) {
  1279.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1280.         }
  1281.         // Enable services for CSRF protection (even without forms)
  1282.         $loader->load('security_csrf.xml');
  1283.         if (!class_exists(CsrfExtension::class)) {
  1284.             $container->removeDefinition('twig.extension.security_csrf');
  1285.         }
  1286.     }
  1287.     private function registerSerializerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1288.     {
  1289.         $loader->load('serializer.xml');
  1290.         if (!class_exists(ConstraintViolationListNormalizer::class)) {
  1291.             $container->removeDefinition('serializer.normalizer.constraint_violation_list');
  1292.         }
  1293.         if (!class_exists(ClassDiscriminatorFromClassMetadata::class)) {
  1294.             $container->removeAlias('Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface');
  1295.             $container->removeDefinition('serializer.mapping.class_discriminator_resolver');
  1296.         }
  1297.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1298.         if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
  1299.             $container->removeAlias('serializer.property_accessor');
  1300.             $container->removeDefinition('serializer.normalizer.object');
  1301.         }
  1302.         if (!class_exists(Yaml::class)) {
  1303.             $container->removeDefinition('serializer.encoder.yaml');
  1304.         }
  1305.         $serializerLoaders = [];
  1306.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1307.             if (!$this->annotationsConfigEnabled) {
  1308.                 throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
  1309.             }
  1310.             $annotationLoader = new Definition(
  1311.                 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
  1312.                 [new Reference('annotation_reader')]
  1313.             );
  1314.             $annotationLoader->setPublic(false);
  1315.             $serializerLoaders[] = $annotationLoader;
  1316.         }
  1317.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1318.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
  1319.             $definition->setPublic(false);
  1320.             $serializerLoaders[] = $definition;
  1321.         };
  1322.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1323.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1324.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1325.                 $fileRecorder('xml'$file);
  1326.             }
  1327.             if (
  1328.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1329.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1330.             ) {
  1331.                 $fileRecorder('yml'$file);
  1332.             }
  1333.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1334.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1335.             }
  1336.         }
  1337.         $projectDir $container->getParameter('kernel.project_dir');
  1338.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1339.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1340.         }
  1341.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1342.         $chainLoader->replaceArgument(0$serializerLoaders);
  1343.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1344.         if ($container->getParameter('kernel.debug')) {
  1345.             $container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
  1346.         }
  1347.         if (isset($config['name_converter']) && $config['name_converter']) {
  1348.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1349.         }
  1350.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1351.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1352.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1353.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1354.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1355.         }
  1356.         if ($config['max_depth_handler'] ?? false) {
  1357.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1358.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1359.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1360.         }
  1361.     }
  1362.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerXmlFileLoader $loader)
  1363.     {
  1364.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1365.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1366.         }
  1367.         $loader->load('property_info.xml');
  1368.         if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) {
  1369.             $definition $container->register('property_info.php_doc_extractor''Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
  1370.             $definition->setPrivate(true);
  1371.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1372.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1373.         }
  1374.         if ($container->getParameter('kernel.debug')) {
  1375.             $container->removeDefinition('property_info.cache');
  1376.         }
  1377.     }
  1378.     private function registerLockConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1379.     {
  1380.         $loader->load('lock.xml');
  1381.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1382.             if (=== \count($resourceStores)) {
  1383.                 continue;
  1384.             }
  1385.             // Generate stores
  1386.             $storeDefinitions = [];
  1387.             foreach ($resourceStores as $storeDsn) {
  1388.                 $storeDsn $container->resolveEnvPlaceholders($storeDsnnull$usedEnvs);
  1389.                 $storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class);
  1390.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1391.                 $storeDefinition->setArguments([$storeDsn]);
  1392.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1393.                 $storeDefinition = new Reference($storeDefinitionId);
  1394.                 $storeDefinitions[] = $storeDefinition;
  1395.             }
  1396.             // Wrap array of stores with CombinedStore
  1397.             if (\count($storeDefinitions) > 1) {
  1398.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1399.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1400.                 $container->setDefinition('lock.'.$resourceName.'.store'$combinedDefinition);
  1401.             } else {
  1402.                 $container->setAlias('lock.'.$resourceName.'.store', new Alias((string) $storeDefinitions[0], false));
  1403.             }
  1404.             // Generate factories for each resource
  1405.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1406.             $factoryDefinition->replaceArgument(0, new Reference('lock.'.$resourceName.'.store'));
  1407.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1408.             // Generate services for lock instances
  1409.             $lockDefinition = new Definition(Lock::class);
  1410.             $lockDefinition->setPublic(false);
  1411.             $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
  1412.             $lockDefinition->setArguments([$resourceName]);
  1413.             $container->setDefinition('lock.'.$resourceName$lockDefinition);
  1414.             // provide alias for default resource
  1415.             if ('default' === $resourceName) {
  1416.                 $container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store'false));
  1417.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1418.                 $container->setAlias('lock', new Alias('lock.'.$resourceNamefalse));
  1419.                 $container->setAlias(StoreInterface::class, new Alias('lock.store'false));
  1420.                 $container->setAlias(PersistingStoreInterface::class, new Alias('lock.store'false));
  1421.                 $container->setAlias(Factory::class, new Alias('lock.factory'false));
  1422.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1423.                 $container->setAlias(LockInterface::class, new Alias('lock'false));
  1424.             } else {
  1425.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'StoreInterface::class, $resourceName.'.lock.store');
  1426.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'PersistingStoreInterface::class, $resourceName.'.lock.store');
  1427.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'Factory::class, $resourceName.'.lock.factory');
  1428.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1429.                 $container->registerAliasForArgument('lock.'.$resourceNameLockInterface::class, $resourceName.'.lock');
  1430.             }
  1431.         }
  1432.     }
  1433.     private function registerMessengerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $validationConfig)
  1434.     {
  1435.         if (!interface_exists(MessageBusInterface::class)) {
  1436.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1437.         }
  1438.         $loader->load('messenger.xml');
  1439.         if (class_exists(AmqpTransportFactory::class)) {
  1440.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1441.         }
  1442.         if (class_exists(RedisTransportFactory::class)) {
  1443.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1444.         }
  1445.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1446.             $config['default_bus'] = key($config['buses']);
  1447.         }
  1448.         $defaultMiddleware = [
  1449.             'before' => [
  1450.                 ['id' => 'add_bus_name_stamp_middleware'],
  1451.                 ['id' => 'reject_redelivered_message_middleware'],
  1452.                 ['id' => 'dispatch_after_current_bus'],
  1453.                 ['id' => 'failed_message_processing_middleware'],
  1454.             ],
  1455.             'after' => [
  1456.                 ['id' => 'send_message'],
  1457.                 ['id' => 'handle_message'],
  1458.             ],
  1459.         ];
  1460.         foreach ($config['buses'] as $busId => $bus) {
  1461.             $middleware $bus['middleware'];
  1462.             if ($bus['default_middleware']) {
  1463.                 if ('allow_no_handlers' === $bus['default_middleware']) {
  1464.                     $defaultMiddleware['after'][1]['arguments'] = [true];
  1465.                 } else {
  1466.                     unset($defaultMiddleware['after'][1]['arguments']);
  1467.                 }
  1468.                 // argument to add_bus_name_stamp_middleware
  1469.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1470.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1471.             }
  1472.             foreach ($middleware as $middlewareItem) {
  1473.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1474.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1475.                 }
  1476.             }
  1477.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1478.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1479.             }
  1480.             $container->setParameter($busId.'.middleware'$middleware);
  1481.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1482.             if ($busId === $config['default_bus']) {
  1483.                 $container->setAlias('message_bus'$busId)->setPublic(true)->setDeprecated(true'The "%alias_id%" service is deprecated, use the "messenger.default_bus" service instead.');
  1484.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1485.                 $container->setAlias(MessageBusInterface::class, $busId);
  1486.             } else {
  1487.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1488.             }
  1489.         }
  1490.         if (empty($config['transports'])) {
  1491.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1492.             $container->removeDefinition('messenger.transport.amqp.factory');
  1493.             $container->removeDefinition('messenger.transport.redis.factory');
  1494.         } else {
  1495.             $container->getDefinition('messenger.transport.symfony_serializer')
  1496.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1497.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1498.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1499.         }
  1500.         $senderAliases = [];
  1501.         $transportRetryReferences = [];
  1502.         foreach ($config['transports'] as $name => $transport) {
  1503.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1504.             $transportDefinition = (new Definition(TransportInterface::class))
  1505.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1506.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1507.                 ->addTag('messenger.receiver', ['alias' => $name])
  1508.             ;
  1509.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1510.             $senderAliases[$name] = $transportId;
  1511.             if (null !== $transport['retry_strategy']['service']) {
  1512.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1513.             } else {
  1514.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1515.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1516.                 $retryDefinition
  1517.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1518.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1519.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1520.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1521.                 $container->setDefinition($retryServiceId$retryDefinition);
  1522.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1523.             }
  1524.         }
  1525.         $senderReferences = [];
  1526.         // alias => service_id
  1527.         foreach ($senderAliases as $alias => $serviceId) {
  1528.             $senderReferences[$alias] = new Reference($serviceId);
  1529.         }
  1530.         // service_id => service_id
  1531.         foreach ($senderAliases as $serviceId) {
  1532.             $senderReferences[$serviceId] = new Reference($serviceId);
  1533.         }
  1534.         $messageToSendersMapping = [];
  1535.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1536.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1537.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1538.             }
  1539.             // make sure senderAliases contains all senders
  1540.             foreach ($messageConfiguration['senders'] as $sender) {
  1541.                 if (!isset($senderReferences[$sender])) {
  1542.                     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));
  1543.                 }
  1544.             }
  1545.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1546.         }
  1547.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1548.         $container->getDefinition('messenger.senders_locator')
  1549.             ->replaceArgument(0$messageToSendersMapping)
  1550.             ->replaceArgument(1$sendersServiceLocator)
  1551.         ;
  1552.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1553.             ->replaceArgument(0$sendersServiceLocator)
  1554.         ;
  1555.         $container->getDefinition('messenger.retry_strategy_locator')
  1556.             ->replaceArgument(0$transportRetryReferences);
  1557.         if ($config['failure_transport']) {
  1558.             if (!isset($senderReferences[$config['failure_transport']])) {
  1559.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1560.             }
  1561.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1562.                 ->replaceArgument(0$senderReferences[$config['failure_transport']]);
  1563.             $container->getDefinition('console.command.messenger_failed_messages_retry')
  1564.                 ->replaceArgument(0$config['failure_transport']);
  1565.             $container->getDefinition('console.command.messenger_failed_messages_show')
  1566.                 ->replaceArgument(0$config['failure_transport']);
  1567.             $container->getDefinition('console.command.messenger_failed_messages_remove')
  1568.                 ->replaceArgument(0$config['failure_transport']);
  1569.         } else {
  1570.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1571.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1572.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1573.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1574.         }
  1575.     }
  1576.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1577.     {
  1578.         if (!class_exists(DefaultMarshaller::class)) {
  1579.             $container->removeDefinition('cache.default_marshaller');
  1580.         }
  1581.         $version = new Parameter('container.build_id');
  1582.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1583.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1584.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1585.         if (isset($config['prefix_seed'])) {
  1586.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1587.         }
  1588.         if ($container->hasParameter('cache.prefix.seed')) {
  1589.             // Inline any env vars referenced in the parameter
  1590.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1591.         }
  1592.         foreach (['doctrine''psr6''redis''memcached''pdo'] as $name) {
  1593.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1594.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1595.             }
  1596.         }
  1597.         foreach (['app''system'] as $name) {
  1598.             $config['pools']['cache.'.$name] = [
  1599.                 'adapters' => [$config[$name]],
  1600.                 'public' => true,
  1601.                 'tags' => false,
  1602.             ];
  1603.         }
  1604.         foreach ($config['pools'] as $name => $pool) {
  1605.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1606.             foreach ($pool['adapters'] as $provider => $adapter) {
  1607.                 if ($config['pools'][$adapter]['tags'] ?? false) {
  1608.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1609.                 }
  1610.             }
  1611.             if (=== \count($pool['adapters'])) {
  1612.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1613.                     $pool['provider'] = $provider;
  1614.                 }
  1615.                 $definition = new ChildDefinition($adapter);
  1616.             } else {
  1617.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1618.                 $pool['reset'] = 'reset';
  1619.             }
  1620.             if ($pool['tags']) {
  1621.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1622.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1623.                 }
  1624.                 $container->register($nameTagAwareAdapter::class)
  1625.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1626.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1627.                     ->setPublic($pool['public'])
  1628.                 ;
  1629.                 $pool['name'] = $name;
  1630.                 $pool['public'] = false;
  1631.                 $name '.'.$name.'.inner';
  1632.                 if (!\in_array($pool['name'], ['cache.app''cache.system'], true)) {
  1633.                     $container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
  1634.                     $container->registerAliasForArgument($nameCacheInterface::class, $pool['name']);
  1635.                     $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name']);
  1636.                 }
  1637.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1638.                 $container->register('.'.$name.'.taggable'TagAwareAdapter::class)
  1639.                     ->addArgument(new Reference($name))
  1640.                 ;
  1641.                 $container->registerAliasForArgument('.'.$name.'.taggable'TagAwareCacheInterface::class, $name);
  1642.                 $container->registerAliasForArgument($nameCacheInterface::class);
  1643.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class);
  1644.             }
  1645.             $definition->setPublic($pool['public']);
  1646.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1647.             $definition->addTag('cache.pool'$pool);
  1648.             $container->setDefinition($name$definition);
  1649.         }
  1650.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1651.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1652.             $propertyAccessDefinition->setPublic(false);
  1653.             if (!$container->getParameter('kernel.debug')) {
  1654.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1655.                 $propertyAccessDefinition->setArguments([null0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1656.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1657.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1658.             } else {
  1659.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1660.                 $propertyAccessDefinition->setArguments([0false]);
  1661.             }
  1662.         }
  1663.     }
  1664.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $profilerConfig)
  1665.     {
  1666.         $loader->load('http_client.xml');
  1667.         $container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
  1668.         if (!$hasPsr18 interface_exists(ClientInterface::class)) {
  1669.             $container->removeDefinition('psr18.http_client');
  1670.             $container->removeAlias(ClientInterface::class);
  1671.         }
  1672.         if (!interface_exists(HttpClient::class)) {
  1673.             $container->removeDefinition(HttpClient::class);
  1674.         }
  1675.         $httpClientId $this->isConfigEnabled($container$profilerConfig) ? '.debug.http_client.inner' 'http_client';
  1676.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1677.             if ('http_client' === $name) {
  1678.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1679.             }
  1680.             $scope $scopeConfig['scope'] ?? null;
  1681.             unset($scopeConfig['scope']);
  1682.             if (null === $scope) {
  1683.                 $container->register($nameScopingHttpClient::class)
  1684.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1685.                     ->setArguments([new Reference($httpClientId), $scopeConfig['base_uri'], $scopeConfig])
  1686.                     ->addTag('http_client.client')
  1687.                 ;
  1688.             } else {
  1689.                 $container->register($nameScopingHttpClient::class)
  1690.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1691.                     ->addTag('http_client.client')
  1692.                 ;
  1693.             }
  1694.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  1695.             if ($hasPsr18) {
  1696.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  1697.                     ->replaceArgument(0, new Reference($name));
  1698.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  1699.             }
  1700.         }
  1701.     }
  1702.     private function registerMailerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1703.     {
  1704.         if (!class_exists(Mailer::class)) {
  1705.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  1706.         }
  1707.         $loader->load('mailer.xml');
  1708.         $loader->load('mailer_transports.xml');
  1709.         if (!\count($config['transports']) && null === $config['dsn']) {
  1710.             $config['dsn'] = 'smtp://null';
  1711.         }
  1712.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  1713.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  1714.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  1715.         $classToServices = [
  1716.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  1717.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  1718.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  1719.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  1720.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  1721.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  1722.         ];
  1723.         foreach ($classToServices as $class => $service) {
  1724.             if (!class_exists($class)) {
  1725.                 $container->removeDefinition($service);
  1726.             }
  1727.         }
  1728.         $recipients $config['envelope']['recipients'] ?? null;
  1729.         $sender $config['envelope']['sender'] ?? null;
  1730.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  1731.         $envelopeListener->setArgument(0$sender);
  1732.         $envelopeListener->setArgument(1$recipients);
  1733.     }
  1734.     /**
  1735.      * {@inheritdoc}
  1736.      */
  1737.     public function getXsdValidationBasePath()
  1738.     {
  1739.         return \dirname(__DIR__).'/Resources/config/schema';
  1740.     }
  1741.     public function getNamespace()
  1742.     {
  1743.         return 'http://symfony.com/schema/dic/symfony';
  1744.     }
  1745. }