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

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