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

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