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.             'container.service_locator',
  416.             'container.service_subscriber',
  417.             'kernel.event_subscriber',
  418.             'kernel.locale_aware',
  419.             'kernel.reset',
  420.         ]);
  421.     }
  422.     /**
  423.      * {@inheritdoc}
  424.      */
  425.     public function getConfiguration(array $configContainerBuilder $container)
  426.     {
  427.         return new Configuration($container->getParameter('kernel.debug'));
  428.     }
  429.     private function registerFormConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  430.     {
  431.         $loader->load('form.xml');
  432.         if (null === $config['form']['csrf_protection']['enabled']) {
  433.             $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
  434.         }
  435.         if ($this->isConfigEnabled($container$config['form']['csrf_protection'])) {
  436.             $loader->load('form_csrf.xml');
  437.             $container->setParameter('form.type_extension.csrf.enabled'true);
  438.             $container->setParameter('form.type_extension.csrf.field_name'$config['form']['csrf_protection']['field_name']);
  439.         } else {
  440.             $container->setParameter('form.type_extension.csrf.enabled'false);
  441.         }
  442.         if (!class_exists(Translator::class)) {
  443.             $container->removeDefinition('form.type_extension.upload.validator');
  444.         }
  445.         if (!method_exists(CachingFactoryDecorator::class, 'reset')) {
  446.             $container->getDefinition('form.choice_list_factory.cached')
  447.                 ->clearTag('kernel.reset')
  448.             ;
  449.         }
  450.     }
  451.     private function registerEsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  452.     {
  453.         if (!$this->isConfigEnabled($container$config)) {
  454.             $container->removeDefinition('fragment.renderer.esi');
  455.             return;
  456.         }
  457.         $loader->load('esi.xml');
  458.     }
  459.     private function registerSsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  460.     {
  461.         if (!$this->isConfigEnabled($container$config)) {
  462.             $container->removeDefinition('fragment.renderer.ssi');
  463.             return;
  464.         }
  465.         $loader->load('ssi.xml');
  466.     }
  467.     private function registerFragmentsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  468.     {
  469.         if (!$this->isConfigEnabled($container$config)) {
  470.             $container->removeDefinition('fragment.renderer.hinclude');
  471.             return;
  472.         }
  473.         if ($container->hasParameter('fragment.renderer.hinclude.global_template') && '' !== $container->getParameter('fragment.renderer.hinclude.global_template') && null !== $config['hinclude_default_template']) {
  474.             throw new \LogicException('You cannot set both "templating.hinclude_default_template" and "fragments.hinclude_default_template", please only use "fragments.hinclude_default_template".');
  475.         }
  476.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  477.         $loader->load('fragment_listener.xml');
  478.         $container->setParameter('fragment.path'$config['path']);
  479.     }
  480.     private function registerProfilerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  481.     {
  482.         if (!$this->isConfigEnabled($container$config)) {
  483.             // this is needed for the WebProfiler to work even if the profiler is disabled
  484.             $container->setParameter('data_collector.templates', []);
  485.             return;
  486.         }
  487.         $loader->load('profiling.xml');
  488.         $loader->load('collectors.xml');
  489.         $loader->load('cache_debug.xml');
  490.         if ($this->formConfigEnabled) {
  491.             $loader->load('form_debug.xml');
  492.         }
  493.         if ($this->validatorConfigEnabled) {
  494.             $loader->load('validator_debug.xml');
  495.         }
  496.         if ($this->translationConfigEnabled) {
  497.             $loader->load('translation_debug.xml');
  498.             $container->getDefinition('translator.data_collector')->setDecoratedService('translator');
  499.         }
  500.         if ($this->messengerConfigEnabled) {
  501.             $loader->load('messenger_debug.xml');
  502.         }
  503.         if ($this->mailerConfigEnabled) {
  504.             $loader->load('mailer_debug.xml');
  505.         }
  506.         if ($this->httpClientConfigEnabled) {
  507.             $loader->load('http_client_debug.xml');
  508.         }
  509.         $container->setParameter('profiler_listener.only_exceptions'$config['only_exceptions']);
  510.         $container->setParameter('profiler_listener.only_master_requests'$config['only_master_requests']);
  511.         // Choose storage class based on the DSN
  512.         [$class] = explode(':'$config['dsn'], 2);
  513.         if ('file' !== $class) {
  514.             throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.'$class));
  515.         }
  516.         $container->setParameter('profiler.storage.dsn'$config['dsn']);
  517.         $container->getDefinition('profiler')
  518.             ->addArgument($config['collect'])
  519.             ->addTag('kernel.reset', ['method' => 'reset']);
  520.     }
  521.     private function registerWorkflowConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  522.     {
  523.         if (!$config['enabled']) {
  524.             $container->removeDefinition('console.command.workflow_dump');
  525.             return;
  526.         }
  527.         if (!class_exists(Workflow\Workflow::class)) {
  528.             throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed. Try running "composer require symfony/workflow".');
  529.         }
  530.         $loader->load('workflow.xml');
  531.         $registryDefinition $container->getDefinition('workflow.registry');
  532.         foreach ($config['workflows'] as $name => $workflow) {
  533.             $type $workflow['type'];
  534.             $workflowId sprintf('%s.%s'$type$name);
  535.             // Process Metadata (workflow + places (transition is done in the "create transition" block))
  536.             $metadataStoreDefinition = new Definition(Workflow\Metadata\InMemoryMetadataStore::class, [[], [], null]);
  537.             if ($workflow['metadata']) {
  538.                 $metadataStoreDefinition->replaceArgument(0$workflow['metadata']);
  539.             }
  540.             $placesMetadata = [];
  541.             foreach ($workflow['places'] as $place) {
  542.                 if ($place['metadata']) {
  543.                     $placesMetadata[$place['name']] = $place['metadata'];
  544.                 }
  545.             }
  546.             if ($placesMetadata) {
  547.                 $metadataStoreDefinition->replaceArgument(1$placesMetadata);
  548.             }
  549.             // Create transitions
  550.             $transitions = [];
  551.             $guardsConfiguration = [];
  552.             $transitionsMetadataDefinition = new Definition(\SplObjectStorage::class);
  553.             // Global transition counter per workflow
  554.             $transitionCounter 0;
  555.             foreach ($workflow['transitions'] as $transition) {
  556.                 if ('workflow' === $type) {
  557.                     $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]);
  558.                     $transitionDefinition->setPublic(false);
  559.                     $transitionId sprintf('%s.transition.%s'$workflowId$transitionCounter++);
  560.                     $container->setDefinition($transitionId$transitionDefinition);
  561.                     $transitions[] = new Reference($transitionId);
  562.                     if (isset($transition['guard'])) {
  563.                         $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  564.                         $configuration->addArgument(new Reference($transitionId));
  565.                         $configuration->addArgument($transition['guard']);
  566.                         $configuration->setPublic(false);
  567.                         $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  568.                         $guardsConfiguration[$eventName][] = $configuration;
  569.                     }
  570.                     if ($transition['metadata']) {
  571.                         $transitionsMetadataDefinition->addMethodCall('attach', [
  572.                             new Reference($transitionId),
  573.                             $transition['metadata'],
  574.                         ]);
  575.                     }
  576.                 } elseif ('state_machine' === $type) {
  577.                     foreach ($transition['from'] as $from) {
  578.                         foreach ($transition['to'] as $to) {
  579.                             $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from$to]);
  580.                             $transitionDefinition->setPublic(false);
  581.                             $transitionId sprintf('%s.transition.%s'$workflowId$transitionCounter++);
  582.                             $container->setDefinition($transitionId$transitionDefinition);
  583.                             $transitions[] = new Reference($transitionId);
  584.                             if (isset($transition['guard'])) {
  585.                                 $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  586.                                 $configuration->addArgument(new Reference($transitionId));
  587.                                 $configuration->addArgument($transition['guard']);
  588.                                 $configuration->setPublic(false);
  589.                                 $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  590.                                 $guardsConfiguration[$eventName][] = $configuration;
  591.                             }
  592.                             if ($transition['metadata']) {
  593.                                 $transitionsMetadataDefinition->addMethodCall('attach', [
  594.                                     new Reference($transitionId),
  595.                                     $transition['metadata'],
  596.                                 ]);
  597.                             }
  598.                         }
  599.                     }
  600.                 }
  601.             }
  602.             $metadataStoreDefinition->replaceArgument(2$transitionsMetadataDefinition);
  603.             // Create places
  604.             $places array_column($workflow['places'], 'name');
  605.             $initialMarking $workflow['initial_marking'] ?? $workflow['initial_place'] ?? [];
  606.             // Create a Definition
  607.             $definitionDefinition = new Definition(Workflow\Definition::class);
  608.             $definitionDefinition->setPublic(false);
  609.             $definitionDefinition->addArgument($places);
  610.             $definitionDefinition->addArgument($transitions);
  611.             $definitionDefinition->addArgument($initialMarking);
  612.             $definitionDefinition->addArgument($metadataStoreDefinition);
  613.             $definitionDefinition->addTag('workflow.definition', [
  614.                 'name' => $name,
  615.                 'type' => $type,
  616.             ]);
  617.             // Create MarkingStore
  618.             if (isset($workflow['marking_store']['type'])) {
  619.                 $markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']);
  620.                 if ('method' === $workflow['marking_store']['type']) {
  621.                     $markingStoreDefinition->setArguments([
  622.                         'state_machine' === $type//single state
  623.                         $workflow['marking_store']['property'] ?? 'marking',
  624.                     ]);
  625.                 } else {
  626.                     foreach ($workflow['marking_store']['arguments'] as $argument) {
  627.                         $markingStoreDefinition->addArgument($argument);
  628.                     }
  629.                 }
  630.             } elseif (isset($workflow['marking_store']['service'])) {
  631.                 $markingStoreDefinition = new Reference($workflow['marking_store']['service']);
  632.             }
  633.             // Create Workflow
  634.             $workflowDefinition = new ChildDefinition(sprintf('%s.abstract'$type));
  635.             $workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition'$workflowId)));
  636.             if (isset($markingStoreDefinition)) {
  637.                 $workflowDefinition->replaceArgument(1$markingStoreDefinition);
  638.             }
  639.             $workflowDefinition->replaceArgument(3$name);
  640.             // Store to container
  641.             $container->setDefinition($workflowId$workflowDefinition);
  642.             $container->setDefinition(sprintf('%s.definition'$workflowId), $definitionDefinition);
  643.             $container->registerAliasForArgument($workflowIdWorkflowInterface::class, $name.'.'.$type);
  644.             // Validate Workflow
  645.             $validator null;
  646.             switch (true) {
  647.                 case 'state_machine' === $workflow['type']:
  648.                     $validator = new Workflow\Validator\StateMachineValidator();
  649.                     break;
  650.                 case 'single_state' === ($workflow['marking_store']['type'] ?? null):
  651.                     $validator = new Workflow\Validator\WorkflowValidator(true);
  652.                     break;
  653.                 case 'multiple_state' === ($workflow['marking_store']['type'] ?? false):
  654.                     $validator = new Workflow\Validator\WorkflowValidator(false);
  655.                     break;
  656.             }
  657.             if ($validator) {
  658.                 $trs array_map(function (Reference $ref) use ($container): Workflow\Transition {
  659.                     return $container->get((string) $ref);
  660.                 }, $transitions);
  661.                 $realDefinition = new Workflow\Definition($places$trs$initialMarking);
  662.                 $validator->validate($realDefinition$name);
  663.             }
  664.             // Add workflow to Registry
  665.             if ($workflow['supports']) {
  666.                 foreach ($workflow['supports'] as $supportedClassName) {
  667.                     $strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, [$supportedClassName]);
  668.                     $strategyDefinition->setPublic(false);
  669.                     $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
  670.                 }
  671.             } elseif (isset($workflow['support_strategy'])) {
  672.                 $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), new Reference($workflow['support_strategy'])]);
  673.             }
  674.             // Enable the AuditTrail
  675.             if ($workflow['audit_trail']['enabled']) {
  676.                 $listener = new Definition(Workflow\EventListener\AuditTrailListener::class);
  677.                 $listener->setPrivate(true);
  678.                 $listener->addTag('monolog.logger', ['channel' => 'workflow']);
  679.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave'$name), 'method' => 'onLeave']);
  680.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition'$name), 'method' => 'onTransition']);
  681.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter'$name), 'method' => 'onEnter']);
  682.                 $listener->addArgument(new Reference('logger'));
  683.                 $container->setDefinition(sprintf('%s.listener.audit_trail'$workflowId), $listener);
  684.             }
  685.             // Add Guard Listener
  686.             if ($guardsConfiguration) {
  687.                 if (!class_exists(ExpressionLanguage::class)) {
  688.                     throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
  689.                 }
  690.                 if (!class_exists(Security::class)) {
  691.                     throw new LogicException('Cannot guard workflows as the Security component is not installed. Try running "composer require symfony/security-core".');
  692.                 }
  693.                 $guard = new Definition(Workflow\EventListener\GuardListener::class);
  694.                 $guard->setPrivate(true);
  695.                 $guard->setArguments([
  696.                     $guardsConfiguration,
  697.                     new Reference('workflow.security.expression_language'),
  698.                     new Reference('security.token_storage'),
  699.                     new Reference('security.authorization_checker'),
  700.                     new Reference('security.authentication.trust_resolver'),
  701.                     new Reference('security.role_hierarchy'),
  702.                     new Reference('validator'ContainerInterface::NULL_ON_INVALID_REFERENCE),
  703.                 ]);
  704.                 foreach ($guardsConfiguration as $eventName => $config) {
  705.                     $guard->addTag('kernel.event_listener', ['event' => $eventName'method' => 'onTransition']);
  706.                 }
  707.                 $container->setDefinition(sprintf('%s.listener.guard'$workflowId), $guard);
  708.                 $container->setParameter('workflow.has_guard_listeners'true);
  709.             }
  710.         }
  711.     }
  712.     private function registerDebugConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  713.     {
  714.         $loader->load('debug_prod.xml');
  715.         if (class_exists(Stopwatch::class)) {
  716.             $container->register('debug.stopwatch'Stopwatch::class)
  717.                 ->addArgument(true)
  718.                 ->setPrivate(true)
  719.                 ->addTag('kernel.reset', ['method' => 'reset']);
  720.             $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch'false));
  721.         }
  722.         $debug $container->getParameter('kernel.debug');
  723.         if ($debug) {
  724.             $container->setParameter('debug.container.dump''%kernel.cache_dir%/%kernel.container_class%.xml');
  725.         }
  726.         if ($debug && class_exists(Stopwatch::class)) {
  727.             $loader->load('debug.xml');
  728.         }
  729.         $definition $container->findDefinition('debug.debug_handlers_listener');
  730.         if (false === $config['log']) {
  731.             $definition->replaceArgument(1null);
  732.         } elseif (true !== $config['log']) {
  733.             $definition->replaceArgument(2$config['log']);
  734.         }
  735.         if (!$config['throw']) {
  736.             $container->setParameter('debug.error_handler.throw_at'0);
  737.         }
  738.         if ($debug && class_exists(DebugProcessor::class)) {
  739.             $definition = new Definition(DebugProcessor::class);
  740.             $definition->setPublic(false);
  741.             $definition->addArgument(new Reference('request_stack'));
  742.             $container->setDefinition('debug.log_processor'$definition);
  743.         }
  744.     }
  745.     private function registerRouterConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  746.     {
  747.         if (!$this->isConfigEnabled($container$config)) {
  748.             $container->removeDefinition('console.command.router_debug');
  749.             $container->removeDefinition('console.command.router_match');
  750.             return;
  751.         }
  752.         $loader->load('routing.xml');
  753.         if ($config['utf8']) {
  754.             $container->getDefinition('routing.loader')->replaceArgument(2, ['utf8' => true]);
  755.         }
  756.         $container->setParameter('router.resource'$config['resource']);
  757.         $container->setParameter('router.cache_class_prefix'$container->getParameter('kernel.container_class')); // deprecated
  758.         $router $container->findDefinition('router.default');
  759.         $argument $router->getArgument(2);
  760.         $argument['strict_requirements'] = $config['strict_requirements'];
  761.         if (isset($config['type'])) {
  762.             $argument['resource_type'] = $config['type'];
  763.         }
  764.         if (!class_exists(CompiledUrlMatcher::class)) {
  765.             $argument['matcher_class'] = $argument['matcher_base_class'] = $argument['matcher_base_class'] ?? RedirectableUrlMatcher::class;
  766.             $argument['matcher_dumper_class'] = PhpMatcherDumper::class;
  767.             $argument['generator_class'] = $argument['generator_base_class'] = $argument['generator_base_class'] ?? UrlGenerator::class;
  768.             $argument['generator_dumper_class'] = PhpGeneratorDumper::class;
  769.         }
  770.         $router->replaceArgument(2$argument);
  771.         $container->setParameter('request_listener.http_port'$config['http_port']);
  772.         $container->setParameter('request_listener.https_port'$config['https_port']);
  773.         if (!$this->annotationsConfigEnabled) {
  774.             return;
  775.         }
  776.         $container->register('routing.loader.annotation'AnnotatedRouteControllerLoader::class)
  777.             ->setPublic(false)
  778.             ->addTag('routing.loader', ['priority' => -10])
  779.             ->addArgument(new Reference('annotation_reader'));
  780.         $container->register('routing.loader.annotation.directory'AnnotationDirectoryLoader::class)
  781.             ->setPublic(false)
  782.             ->addTag('routing.loader', ['priority' => -10])
  783.             ->setArguments([
  784.                 new Reference('file_locator'),
  785.                 new Reference('routing.loader.annotation'),
  786.             ]);
  787.         $container->register('routing.loader.annotation.file'AnnotationFileLoader::class)
  788.             ->setPublic(false)
  789.             ->addTag('routing.loader', ['priority' => -10])
  790.             ->setArguments([
  791.                 new Reference('file_locator'),
  792.                 new Reference('routing.loader.annotation'),
  793.             ]);
  794.     }
  795.     private function registerSessionConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  796.     {
  797.         $loader->load('session.xml');
  798.         // session storage
  799.         $container->setAlias('session.storage'$config['storage_id'])->setPrivate(true);
  800.         $options = ['cache_limiter' => '0'];
  801.         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) {
  802.             if (isset($config[$key])) {
  803.                 $options[$key] = $config[$key];
  804.             }
  805.         }
  806.         if ('auto' === ($options['cookie_secure'] ?? null)) {
  807.             $locator $container->getDefinition('session_listener')->getArgument(0);
  808.             $locator->setValues($locator->getValues() + [
  809.                 'session_storage' => new Reference('session.storage'ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
  810.                 'request_stack' => new Reference('request_stack'),
  811.             ]);
  812.         }
  813.         $container->setParameter('session.storage.options'$options);
  814.         // session handler (the internal callback registered with PHP session management)
  815.         if (null === $config['handler_id']) {
  816.             // Set the handler class to be null
  817.             $container->getDefinition('session.storage.native')->replaceArgument(1null);
  818.             $container->getDefinition('session.storage.php_bridge')->replaceArgument(0null);
  819.             $container->setAlias('session.handler''session.handler.native_file')->setPrivate(true);
  820.         } else {
  821.             $container->resolveEnvPlaceholders($config['handler_id'], null$usedEnvs);
  822.             if ($usedEnvs || preg_match('#^[a-z]++://#'$config['handler_id'])) {
  823.                 $id '.cache_connection.'.ContainerBuilder::hash($config['handler_id']);
  824.                 $container->getDefinition('session.abstract_handler')
  825.                     ->replaceArgument(0$container->hasDefinition($id) ? new Reference($id) : $config['handler_id']);
  826.                 $container->setAlias('session.handler''session.abstract_handler')->setPrivate(true);
  827.             } else {
  828.                 $container->setAlias('session.handler'$config['handler_id'])->setPrivate(true);
  829.             }
  830.         }
  831.         $container->setParameter('session.save_path'$config['save_path']);
  832.         $container->setParameter('session.metadata.update_threshold'$config['metadata_update_threshold']);
  833.     }
  834.     private function registerRequestConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  835.     {
  836.         if ($config['formats']) {
  837.             $loader->load('request.xml');
  838.             $listener $container->getDefinition('request.add_request_formats_listener');
  839.             $listener->replaceArgument(0$config['formats']);
  840.         }
  841.     }
  842.     private function registerTemplatingConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  843.     {
  844.         $loader->load('templating.xml');
  845.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  846.         if ($container->getParameter('kernel.debug')) {
  847.             $logger = new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE);
  848.             $container->getDefinition('templating.loader.cache')
  849.                 ->addTag('monolog.logger', ['channel' => 'templating'])
  850.                 ->addMethodCall('setLogger', [$logger]);
  851.             $container->getDefinition('templating.loader.chain')
  852.                 ->addTag('monolog.logger', ['channel' => 'templating'])
  853.                 ->addMethodCall('setLogger', [$logger]);
  854.         }
  855.         if (!empty($config['loaders'])) {
  856.             $loaders array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);
  857.             // Use a delegation unless only a single loader was registered
  858.             if (=== \count($loaders)) {
  859.                 $container->setAlias('templating.loader', (string) reset($loaders))->setPrivate(true);
  860.             } else {
  861.                 $container->getDefinition('templating.loader.chain')->addArgument($loaders);
  862.                 $container->setAlias('templating.loader''templating.loader.chain')->setPrivate(true);
  863.             }
  864.         }
  865.         $container->setParameter('templating.loader.cache.path'null);
  866.         if (isset($config['cache'])) {
  867.             // Wrap the existing loader with cache (must happen after loaders are registered)
  868.             $container->setDefinition('templating.loader.wrapped'$container->findDefinition('templating.loader'));
  869.             $loaderCache $container->getDefinition('templating.loader.cache');
  870.             $container->setParameter('templating.loader.cache.path'$config['cache']);
  871.             $container->setDefinition('templating.loader'$loaderCache);
  872.         }
  873.         $container->setParameter('templating.engines'$config['engines']);
  874.         $engines array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
  875.         // Use a delegation unless only a single engine was registered
  876.         if (=== \count($engines)) {
  877.             $container->setAlias('templating', (string) reset($engines))->setPublic(true);
  878.         } else {
  879.             $templateEngineDefinition $container->getDefinition('templating.engine.delegating');
  880.             foreach ($engines as $engine) {
  881.                 $templateEngineDefinition->addMethodCall('addEngine', [$engine]);
  882.             }
  883.             $container->setAlias('templating''templating.engine.delegating')->setPublic(true);
  884.         }
  885.         $container->getDefinition('fragment.renderer.hinclude')
  886.             ->addTag('kernel.fragment_renderer', ['alias' => 'hinclude'])
  887.             ->replaceArgument(0, new Reference('templating'))
  888.         ;
  889.         // configure the PHP engine if needed
  890.         if (\in_array('php'$config['engines'], true)) {
  891.             $loader->load('templating_php.xml');
  892.             $container->setParameter('templating.helper.form.resources'$config['form']['resources']);
  893.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  894.                 $loader->load('templating_debug.xml');
  895.                 $container->setDefinition('templating.engine.php'$container->findDefinition('debug.templating.engine.php'));
  896.                 $container->setAlias('debug.templating.engine.php''templating.engine.php')->setPrivate(true);
  897.             }
  898.             if ($container->has('assets.packages')) {
  899.                 $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages'));
  900.             } else {
  901.                 $container->removeDefinition('templating.helper.assets');
  902.             }
  903.         }
  904.     }
  905.     private function registerAssetsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  906.     {
  907.         $loader->load('assets.xml');
  908.         if ($config['version_strategy']) {
  909.             $defaultVersion = new Reference($config['version_strategy']);
  910.         } else {
  911.             $defaultVersion $this->createVersion($container$config['version'], $config['version_format'], $config['json_manifest_path'], '_default');
  912.         }
  913.         $defaultPackage $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
  914.         $container->setDefinition('assets._default_package'$defaultPackage);
  915.         $namedPackages = [];
  916.         foreach ($config['packages'] as $name => $package) {
  917.             if (null !== $package['version_strategy']) {
  918.                 $version = new Reference($package['version_strategy']);
  919.             } elseif (!\array_key_exists('version'$package) && null === $package['json_manifest_path']) {
  920.                 // if neither version nor json_manifest_path are specified, use the default
  921.                 $version $defaultVersion;
  922.             } else {
  923.                 // let format fallback to main version_format
  924.                 $format $package['version_format'] ?: $config['version_format'];
  925.                 $version $package['version'] ?? null;
  926.                 $version $this->createVersion($container$version$format$package['json_manifest_path'], $name);
  927.             }
  928.             $container->setDefinition('assets._package_'.$name$this->createPackageDefinition($package['base_path'], $package['base_urls'], $version));
  929.             $container->registerAliasForArgument('assets._package_'.$namePackageInterface::class, $name.'.package');
  930.             $namedPackages[$name] = new Reference('assets._package_'.$name);
  931.         }
  932.         $container->getDefinition('assets.packages')
  933.             ->replaceArgument(0, new Reference('assets._default_package'))
  934.             ->replaceArgument(1$namedPackages)
  935.         ;
  936.     }
  937.     /**
  938.      * Returns a definition for an asset package.
  939.      */
  940.     private function createPackageDefinition(?string $basePath, array $baseUrlsReference $version): Definition
  941.     {
  942.         if ($basePath && $baseUrls) {
  943.             throw new \LogicException('An asset package cannot have base URLs and base paths.');
  944.         }
  945.         $package = new ChildDefinition($baseUrls 'assets.url_package' 'assets.path_package');
  946.         $package
  947.             ->setPublic(false)
  948.             ->replaceArgument(0$baseUrls ?: $basePath)
  949.             ->replaceArgument(1$version)
  950.         ;
  951.         return $package;
  952.     }
  953.     private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPathstring $name): Reference
  954.     {
  955.         // Configuration prevents $version and $jsonManifestPath from being set
  956.         if (null !== $version) {
  957.             $def = new ChildDefinition('assets.static_version_strategy');
  958.             $def
  959.                 ->replaceArgument(0$version)
  960.                 ->replaceArgument(1$format)
  961.             ;
  962.             $container->setDefinition('assets._version_'.$name$def);
  963.             return new Reference('assets._version_'.$name);
  964.         }
  965.         if (null !== $jsonManifestPath) {
  966.             $def = new ChildDefinition('assets.json_manifest_version_strategy');
  967.             $def->replaceArgument(0$jsonManifestPath);
  968.             $container->setDefinition('assets._version_'.$name$def);
  969.             return new Reference('assets._version_'.$name);
  970.         }
  971.         return new Reference('assets.empty_version_strategy');
  972.     }
  973.     private function registerTranslatorConfiguration(array $configContainerBuilder $containerLoaderInterface $loaderstring $defaultLocale)
  974.     {
  975.         if (!$this->isConfigEnabled($container$config)) {
  976.             $container->removeDefinition('console.command.translation_debug');
  977.             $container->removeDefinition('console.command.translation_update');
  978.             return;
  979.         }
  980.         $loader->load('translation.xml');
  981.         // Use the "real" translator instead of the identity default
  982.         $container->setAlias('translator''translator.default')->setPublic(true);
  983.         $container->setAlias('translator.formatter', new Alias($config['formatter'], false));
  984.         $translator $container->findDefinition('translator.default');
  985.         $translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
  986.         $defaultOptions $translator->getArgument(4);
  987.         $defaultOptions['cache_dir'] = $config['cache_dir'];
  988.         $translator->setArgument(4$defaultOptions);
  989.         $container->setParameter('translator.logging'$config['logging']);
  990.         $container->setParameter('translator.default_path'$config['default_path']);
  991.         // Discover translation directories
  992.         $dirs = [];
  993.         $transPaths = [];
  994.         $nonExistingDirs = [];
  995.         if (class_exists(\Symfony\Component\Validator\Validation::class)) {
  996.             $r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
  997.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  998.         }
  999.         if (class_exists(\Symfony\Component\Form\Form::class)) {
  1000.             $r = new \ReflectionClass(\Symfony\Component\Form\Form::class);
  1001.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  1002.         }
  1003.         if (class_exists(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) {
  1004.             $r = new \ReflectionClass(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
  1005.             $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
  1006.         }
  1007.         $defaultDir $container->getParameterBag()->resolveValue($config['default_path']);
  1008.         $rootDir $container->getParameter('kernel.root_dir');
  1009.         foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
  1010.             if ($container->fileExists($dir $bundle['path'].'/Resources/translations') || $container->fileExists($dir $bundle['path'].'/translations')) {
  1011.                 $dirs[] = $dir;
  1012.             } else {
  1013.                 $nonExistingDirs[] = $dir;
  1014.             }
  1015.             if ($container->fileExists($dir $rootDir.sprintf('/Resources/%s/translations'$name))) {
  1016.                 @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.'$dir$defaultDir), \E_USER_DEPRECATED);
  1017.                 $dirs[] = $dir;
  1018.             } else {
  1019.                 $nonExistingDirs[] = $dir;
  1020.             }
  1021.         }
  1022.         foreach ($config['paths'] as $dir) {
  1023.             if ($container->fileExists($dir)) {
  1024.                 $dirs[] = $transPaths[] = $dir;
  1025.             } else {
  1026.                 throw new \UnexpectedValueException(sprintf('"%s" defined in translator.paths does not exist or is not a directory.'$dir));
  1027.             }
  1028.         }
  1029.         if ($container->hasDefinition('console.command.translation_debug')) {
  1030.             $container->getDefinition('console.command.translation_debug')->replaceArgument(5$transPaths);
  1031.         }
  1032.         if ($container->hasDefinition('console.command.translation_update')) {
  1033.             $container->getDefinition('console.command.translation_update')->replaceArgument(6$transPaths);
  1034.         }
  1035.         if (null === $defaultDir) {
  1036.             // allow null
  1037.         } elseif ($container->fileExists($defaultDir)) {
  1038.             $dirs[] = $defaultDir;
  1039.         } else {
  1040.             $nonExistingDirs[] = $defaultDir;
  1041.         }
  1042.         if ($container->fileExists($dir $rootDir.'/Resources/translations')) {
  1043.             if ($dir !== $defaultDir) {
  1044.                 @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.'$dir$defaultDir), \E_USER_DEPRECATED);
  1045.             }
  1046.             $dirs[] = $dir;
  1047.         } else {
  1048.             $nonExistingDirs[] = $dir;
  1049.         }
  1050.         // Register translation resources
  1051.         if ($dirs) {
  1052.             $files = [];
  1053.             foreach ($dirs as $dir) {
  1054.                 $finder Finder::create()
  1055.                     ->followLinks()
  1056.                     ->files()
  1057.                     ->filter(function (\SplFileInfo $file) {
  1058.                         return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  1059.                     })
  1060.                     ->in($dir)
  1061.                     ->sortByName()
  1062.                 ;
  1063.                 foreach ($finder as $file) {
  1064.                     $fileNameParts explode('.'basename($file));
  1065.                     $locale $fileNameParts[\count($fileNameParts) - 2];
  1066.                     if (!isset($files[$locale])) {
  1067.                         $files[$locale] = [];
  1068.                     }
  1069.                     $files[$locale][] = (string) $file;
  1070.                 }
  1071.             }
  1072.             $projectDir $container->getParameter('kernel.project_dir');
  1073.             $options array_merge(
  1074.                 $translator->getArgument(4),
  1075.                 [
  1076.                     'resource_files' => $files,
  1077.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1078.                     'cache_vary' => [
  1079.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1080.                             return str_starts_with($dir$projectDir.'/') ? substr($dir+ \strlen($projectDir)) : $dir;
  1081.                         }, $scannedDirectories),
  1082.                     ],
  1083.                 ]
  1084.             );
  1085.             $translator->replaceArgument(4$options);
  1086.         }
  1087.     }
  1088.     private function registerValidationConfiguration(array $configContainerBuilder $containerXmlFileLoader $loaderbool $propertyInfoEnabled)
  1089.     {
  1090.         if (!$this->validatorConfigEnabled $this->isConfigEnabled($container$config)) {
  1091.             return;
  1092.         }
  1093.         if (!class_exists(\Symfony\Component\Validator\Validation::class)) {
  1094.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1095.         }
  1096.         if (!isset($config['email_validation_mode'])) {
  1097.             $config['email_validation_mode'] = 'loose';
  1098.         }
  1099.         $loader->load('validator.xml');
  1100.         $validatorBuilder $container->getDefinition('validator.builder');
  1101.         if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
  1102.             $calls $validatorBuilder->getMethodCalls();
  1103.             $calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])]];
  1104.             $validatorBuilder->setMethodCalls($calls);
  1105.         }
  1106.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1107.         $files = ['xml' => [], 'yml' => []];
  1108.         $this->registerValidatorMapping($container$config$files);
  1109.         if (!empty($files['xml'])) {
  1110.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1111.         }
  1112.         if (!empty($files['yml'])) {
  1113.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1114.         }
  1115.         $definition $container->findDefinition('validator.email');
  1116.         $definition->replaceArgument(0$config['email_validation_mode']);
  1117.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1118.             if (!$this->annotationsConfigEnabled) {
  1119.                 throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
  1120.             }
  1121.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
  1122.         }
  1123.         if (\array_key_exists('static_method'$config) && $config['static_method']) {
  1124.             foreach ($config['static_method'] as $methodName) {
  1125.                 $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
  1126.             }
  1127.         }
  1128.         if (!$container->getParameter('kernel.debug')) {
  1129.             $validatorBuilder->addMethodCall('setMappingCache', [new Reference('validator.mapping.cache.adapter')]);
  1130.         }
  1131.         $container->setParameter('validator.auto_mapping'$config['auto_mapping']);
  1132.         if (!$propertyInfoEnabled || !class_exists(PropertyInfoLoader::class)) {
  1133.             $container->removeDefinition('validator.property_info_loader');
  1134.         }
  1135.         $container
  1136.             ->getDefinition('validator.not_compromised_password')
  1137.             ->setArgument(2$config['not_compromised_password']['enabled'])
  1138.             ->setArgument(3$config['not_compromised_password']['endpoint'])
  1139.         ;
  1140.     }
  1141.     private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files)
  1142.     {
  1143.         $fileRecorder = function ($extension$path) use (&$files) {
  1144.             $files['yaml' === $extension 'yml' $extension][] = $path;
  1145.         };
  1146.         if (interface_exists(\Symfony\Component\Form\FormInterface::class)) {
  1147.             $reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class);
  1148.             $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
  1149.         }
  1150.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1151.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1152.             if (
  1153.                 $container->fileExists($file $configDir.'/validation.yaml'false) ||
  1154.                 $container->fileExists($file $configDir.'/validation.yml'false)
  1155.             ) {
  1156.                 $fileRecorder('yml'$file);
  1157.             }
  1158.             if ($container->fileExists($file $configDir.'/validation.xml'false)) {
  1159.                 $fileRecorder('xml'$file);
  1160.             }
  1161.             if ($container->fileExists($dir $configDir.'/validation''/^$/')) {
  1162.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1163.             }
  1164.         }
  1165.         $projectDir $container->getParameter('kernel.project_dir');
  1166.         if ($container->fileExists($dir $projectDir.'/config/validator''/^$/')) {
  1167.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1168.         }
  1169.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1170.     }
  1171.     private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
  1172.     {
  1173.         foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
  1174.             $fileRecorder($file->getExtension(), $file->getRealPath());
  1175.         }
  1176.     }
  1177.     private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder)
  1178.     {
  1179.         foreach ($config['mapping']['paths'] as $path) {
  1180.             if (is_dir($path)) {
  1181.                 $this->registerMappingFilesFromDir($path$fileRecorder);
  1182.                 $container->addResource(new DirectoryResource($path'/^$/'));
  1183.             } elseif ($container->fileExists($pathfalse)) {
  1184.                 if (!preg_match('/\.(xml|ya?ml)$/'$path$matches)) {
  1185.                     throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.'$path));
  1186.                 }
  1187.                 $fileRecorder($matches[1], $path);
  1188.             } else {
  1189.                 throw new \RuntimeException(sprintf('Could not open file or directory "%s".'$path));
  1190.             }
  1191.         }
  1192.     }
  1193.     private function registerAnnotationsConfiguration(array $configContainerBuilder $containerLoaderInterface $loader)
  1194.     {
  1195.         if (!$this->annotationsConfigEnabled) {
  1196.             return;
  1197.         }
  1198.         if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
  1199.             throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
  1200.         }
  1201.         $loader->load('annotations.xml');
  1202.         if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  1203.             $container->getDefinition('annotations.dummy_registry')
  1204.                 ->setMethodCalls([['registerLoader', ['class_exists']]]);
  1205.         }
  1206.         if ('none' !== $config['cache']) {
  1207.             if (class_exists(PsrCachedReader::class)) {
  1208.                 $container
  1209.                     ->getDefinition('annotations.cached_reader')
  1210.                     ->setClass(PsrCachedReader::class)
  1211.                     ->replaceArgument(1, new Definition(ArrayAdapter::class))
  1212.                 ;
  1213.             } elseif (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
  1214.                 throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
  1215.             }
  1216.             $cacheService $config['cache'];
  1217.             if ('php_array' === $config['cache']) {
  1218.                 $cacheService class_exists(PsrCachedReader::class) ? 'annotations.cache_adapter' 'annotations.cache';
  1219.                 // Enable warmer only if PHP array is used for cache
  1220.                 $definition $container->findDefinition('annotations.cache_warmer');
  1221.                 $definition->addTag('kernel.cache_warmer');
  1222.             } elseif ('file' === $config['cache']) {
  1223.                 $cacheDir $container->getParameterBag()->resolveValue($config['file_cache_dir']);
  1224.                 if (!is_dir($cacheDir) && false === @mkdir($cacheDir0777true) && !is_dir($cacheDir)) {
  1225.                     throw new \RuntimeException(sprintf('Could not create cache directory "%s".'$cacheDir));
  1226.                 }
  1227.                 $container
  1228.                     ->getDefinition('annotations.filesystem_cache_adapter')
  1229.                     ->replaceArgument(2$cacheDir)
  1230.                 ;
  1231.                 $cacheService class_exists(PsrCachedReader::class) ? 'annotations.filesystem_cache_adapter' 'annotations.filesystem_cache';
  1232.             }
  1233.             $container
  1234.                 ->getDefinition('annotations.cached_reader')
  1235.                 ->replaceArgument(2$config['debug'])
  1236.                 // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
  1237.                 ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
  1238.                 ->addTag('annotations.cached_reader')
  1239.             ;
  1240.             $container->setAlias('annotation_reader''annotations.cached_reader')->setPrivate(true);
  1241.             $container->setAlias(Reader::class, new Alias('annotations.cached_reader'false));
  1242.         } else {
  1243.             $container->removeDefinition('annotations.cached_reader');
  1244.         }
  1245.     }
  1246.     private function registerPropertyAccessConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1247.     {
  1248.         if (!class_exists(PropertyAccessor::class)) {
  1249.             return;
  1250.         }
  1251.         $loader->load('property_access.xml');
  1252.         $container
  1253.             ->getDefinition('property_accessor')
  1254.             ->replaceArgument(0$config['magic_call'])
  1255.             ->replaceArgument(1$config['throw_exception_on_invalid_index'])
  1256.             ->replaceArgument(3$config['throw_exception_on_invalid_property_path'])
  1257.         ;
  1258.     }
  1259.     private function registerSecretsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1260.     {
  1261.         if (!$this->isConfigEnabled($container$config)) {
  1262.             $container->removeDefinition('console.command.secrets_set');
  1263.             $container->removeDefinition('console.command.secrets_list');
  1264.             $container->removeDefinition('console.command.secrets_remove');
  1265.             $container->removeDefinition('console.command.secrets_generate_key');
  1266.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1267.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1268.             return;
  1269.         }
  1270.         $loader->load('secrets.xml');
  1271.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1272.         if ($config['local_dotenv_file']) {
  1273.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1274.         } else {
  1275.             $container->removeDefinition('secrets.local_vault');
  1276.         }
  1277.         if ($config['decryption_env_var']) {
  1278.             if (!preg_match('/^(?:\w*+:)*+\w++$/'$config['decryption_env_var'])) {
  1279.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1280.             }
  1281.             $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1282.         } else {
  1283.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1284.         }
  1285.     }
  1286.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1287.     {
  1288.         if (!$this->isConfigEnabled($container$config)) {
  1289.             return;
  1290.         }
  1291.         if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
  1292.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1293.         }
  1294.         if (!$this->sessionConfigEnabled) {
  1295.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1296.         }
  1297.         // Enable services for CSRF protection (even without forms)
  1298.         $loader->load('security_csrf.xml');
  1299.         if (!class_exists(CsrfExtension::class)) {
  1300.             $container->removeDefinition('twig.extension.security_csrf');
  1301.         }
  1302.     }
  1303.     private function registerSerializerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1304.     {
  1305.         $loader->load('serializer.xml');
  1306.         if (!class_exists(ConstraintViolationListNormalizer::class)) {
  1307.             $container->removeDefinition('serializer.normalizer.constraint_violation_list');
  1308.         }
  1309.         if (!class_exists(ClassDiscriminatorFromClassMetadata::class)) {
  1310.             $container->removeAlias('Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface');
  1311.             $container->removeDefinition('serializer.mapping.class_discriminator_resolver');
  1312.         }
  1313.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1314.         if (!class_exists(PropertyAccessor::class)) {
  1315.             $container->removeAlias('serializer.property_accessor');
  1316.             $container->removeDefinition('serializer.normalizer.object');
  1317.         }
  1318.         if (!class_exists(Yaml::class)) {
  1319.             $container->removeDefinition('serializer.encoder.yaml');
  1320.         }
  1321.         $serializerLoaders = [];
  1322.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1323.             if (!$this->annotationsConfigEnabled) {
  1324.                 throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
  1325.             }
  1326.             $annotationLoader = new Definition(
  1327.                 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
  1328.                 [new Reference('annotation_reader')]
  1329.             );
  1330.             $annotationLoader->setPublic(false);
  1331.             $serializerLoaders[] = $annotationLoader;
  1332.         }
  1333.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1334.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
  1335.             $definition->setPublic(false);
  1336.             $serializerLoaders[] = $definition;
  1337.         };
  1338.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1339.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1340.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1341.                 $fileRecorder('xml'$file);
  1342.             }
  1343.             if (
  1344.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1345.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1346.             ) {
  1347.                 $fileRecorder('yml'$file);
  1348.             }
  1349.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1350.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1351.             }
  1352.         }
  1353.         $projectDir $container->getParameter('kernel.project_dir');
  1354.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1355.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1356.         }
  1357.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1358.         $chainLoader->replaceArgument(0$serializerLoaders);
  1359.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1360.         if ($container->getParameter('kernel.debug')) {
  1361.             $container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
  1362.         }
  1363.         if (isset($config['name_converter']) && $config['name_converter']) {
  1364.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1365.         }
  1366.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1367.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1368.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1369.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1370.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1371.         }
  1372.         if ($config['max_depth_handler'] ?? false) {
  1373.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1374.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1375.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1376.         }
  1377.     }
  1378.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerXmlFileLoader $loader)
  1379.     {
  1380.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1381.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1382.         }
  1383.         $loader->load('property_info.xml');
  1384.         if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) {
  1385.             $definition $container->register('property_info.php_doc_extractor''Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
  1386.             $definition->setPrivate(true);
  1387.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1388.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1389.         }
  1390.         if ($container->getParameter('kernel.debug')) {
  1391.             $container->removeDefinition('property_info.cache');
  1392.         }
  1393.     }
  1394.     private function registerLockConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1395.     {
  1396.         $loader->load('lock.xml');
  1397.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1398.             if (=== \count($resourceStores)) {
  1399.                 continue;
  1400.             }
  1401.             // Generate stores
  1402.             $storeDefinitions = [];
  1403.             foreach ($resourceStores as $storeDsn) {
  1404.                 $storeDsn $container->resolveEnvPlaceholders($storeDsnnull$usedEnvs);
  1405.                 $storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class);
  1406.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1407.                 $storeDefinition->setArguments([$storeDsn]);
  1408.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1409.                 $storeDefinition = new Reference($storeDefinitionId);
  1410.                 $storeDefinitions[] = $storeDefinition;
  1411.             }
  1412.             // Wrap array of stores with CombinedStore
  1413.             if (\count($storeDefinitions) > 1) {
  1414.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1415.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1416.                 $container->setDefinition('lock.'.$resourceName.'.store'$combinedDefinition);
  1417.             } else {
  1418.                 $container->setAlias('lock.'.$resourceName.'.store', new Alias((string) $storeDefinitions[0], false));
  1419.             }
  1420.             // Generate factories for each resource
  1421.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1422.             $factoryDefinition->replaceArgument(0, new Reference('lock.'.$resourceName.'.store'));
  1423.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1424.             // Generate services for lock instances
  1425.             $lockDefinition = new Definition(Lock::class);
  1426.             $lockDefinition->setPublic(false);
  1427.             $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
  1428.             $lockDefinition->setArguments([$resourceName]);
  1429.             $container->setDefinition('lock.'.$resourceName$lockDefinition);
  1430.             // provide alias for default resource
  1431.             if ('default' === $resourceName) {
  1432.                 $container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store'false));
  1433.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1434.                 $container->setAlias('lock', new Alias('lock.'.$resourceNamefalse));
  1435.                 $container->setAlias(StoreInterface::class, new Alias('lock.store'false));
  1436.                 $container->setAlias(PersistingStoreInterface::class, new Alias('lock.store'false));
  1437.                 $container->setAlias(Factory::class, new Alias('lock.factory'false));
  1438.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1439.                 $container->setAlias(LockInterface::class, new Alias('lock'false));
  1440.             } else {
  1441.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'StoreInterface::class, $resourceName.'.lock.store');
  1442.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'PersistingStoreInterface::class, $resourceName.'.lock.store');
  1443.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'Factory::class, $resourceName.'.lock.factory');
  1444.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1445.                 $container->registerAliasForArgument('lock.'.$resourceNameLockInterface::class, $resourceName.'.lock');
  1446.             }
  1447.         }
  1448.     }
  1449.     private function registerMessengerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $validationConfig)
  1450.     {
  1451.         if (!interface_exists(MessageBusInterface::class)) {
  1452.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1453.         }
  1454.         $loader->load('messenger.xml');
  1455.         if (class_exists(AmqpTransportFactory::class)) {
  1456.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1457.         }
  1458.         if (class_exists(RedisTransportFactory::class)) {
  1459.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1460.         }
  1461.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1462.             $config['default_bus'] = key($config['buses']);
  1463.         }
  1464.         $defaultMiddleware = [
  1465.             'before' => [
  1466.                 ['id' => 'add_bus_name_stamp_middleware'],
  1467.                 ['id' => 'reject_redelivered_message_middleware'],
  1468.                 ['id' => 'dispatch_after_current_bus'],
  1469.                 ['id' => 'failed_message_processing_middleware'],
  1470.             ],
  1471.             'after' => [
  1472.                 ['id' => 'send_message'],
  1473.                 ['id' => 'handle_message'],
  1474.             ],
  1475.         ];
  1476.         foreach ($config['buses'] as $busId => $bus) {
  1477.             $middleware $bus['middleware'];
  1478.             if ($bus['default_middleware']) {
  1479.                 if ('allow_no_handlers' === $bus['default_middleware']) {
  1480.                     $defaultMiddleware['after'][1]['arguments'] = [true];
  1481.                 } else {
  1482.                     unset($defaultMiddleware['after'][1]['arguments']);
  1483.                 }
  1484.                 // argument to add_bus_name_stamp_middleware
  1485.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1486.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1487.             }
  1488.             foreach ($middleware as $middlewareItem) {
  1489.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1490.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1491.                 }
  1492.             }
  1493.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1494.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1495.             }
  1496.             $container->setParameter($busId.'.middleware'$middleware);
  1497.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1498.             if ($busId === $config['default_bus']) {
  1499.                 $container->setAlias('message_bus'$busId)->setPublic(true)->setDeprecated(true'The "%alias_id%" service is deprecated, use the "messenger.default_bus" service instead.');
  1500.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1501.                 $container->setAlias(MessageBusInterface::class, $busId);
  1502.             } else {
  1503.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1504.             }
  1505.         }
  1506.         if (empty($config['transports'])) {
  1507.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1508.             $container->removeDefinition('messenger.transport.amqp.factory');
  1509.             $container->removeDefinition('messenger.transport.redis.factory');
  1510.         } else {
  1511.             $container->getDefinition('messenger.transport.symfony_serializer')
  1512.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1513.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1514.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1515.         }
  1516.         $senderAliases = [];
  1517.         $transportRetryReferences = [];
  1518.         foreach ($config['transports'] as $name => $transport) {
  1519.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1520.             $transportDefinition = (new Definition(TransportInterface::class))
  1521.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1522.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1523.                 ->addTag('messenger.receiver', ['alias' => $name])
  1524.             ;
  1525.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1526.             $senderAliases[$name] = $transportId;
  1527.             if (null !== $transport['retry_strategy']['service']) {
  1528.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1529.             } else {
  1530.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1531.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1532.                 $retryDefinition
  1533.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1534.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1535.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1536.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1537.                 $container->setDefinition($retryServiceId$retryDefinition);
  1538.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1539.             }
  1540.         }
  1541.         $senderReferences = [];
  1542.         // alias => service_id
  1543.         foreach ($senderAliases as $alias => $serviceId) {
  1544.             $senderReferences[$alias] = new Reference($serviceId);
  1545.         }
  1546.         // service_id => service_id
  1547.         foreach ($senderAliases as $serviceId) {
  1548.             $senderReferences[$serviceId] = new Reference($serviceId);
  1549.         }
  1550.         $messageToSendersMapping = [];
  1551.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1552.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1553.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1554.             }
  1555.             // make sure senderAliases contains all senders
  1556.             foreach ($messageConfiguration['senders'] as $sender) {
  1557.                 if (!isset($senderReferences[$sender])) {
  1558.                     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));
  1559.                 }
  1560.             }
  1561.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1562.         }
  1563.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1564.         $container->getDefinition('messenger.senders_locator')
  1565.             ->replaceArgument(0$messageToSendersMapping)
  1566.             ->replaceArgument(1$sendersServiceLocator)
  1567.         ;
  1568.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1569.             ->replaceArgument(0$sendersServiceLocator)
  1570.         ;
  1571.         $container->getDefinition('messenger.retry_strategy_locator')
  1572.             ->replaceArgument(0$transportRetryReferences);
  1573.         if ($config['failure_transport']) {
  1574.             if (!isset($senderReferences[$config['failure_transport']])) {
  1575.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1576.             }
  1577.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1578.                 ->replaceArgument(0$senderReferences[$config['failure_transport']]);
  1579.             $container->getDefinition('console.command.messenger_failed_messages_retry')
  1580.                 ->replaceArgument(0$config['failure_transport']);
  1581.             $container->getDefinition('console.command.messenger_failed_messages_show')
  1582.                 ->replaceArgument(0$config['failure_transport']);
  1583.             $container->getDefinition('console.command.messenger_failed_messages_remove')
  1584.                 ->replaceArgument(0$config['failure_transport']);
  1585.         } else {
  1586.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1587.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1588.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1589.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1590.         }
  1591.     }
  1592.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1593.     {
  1594.         if (!class_exists(DefaultMarshaller::class)) {
  1595.             $container->removeDefinition('cache.default_marshaller');
  1596.         }
  1597.         $version = new Parameter('container.build_id');
  1598.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1599.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1600.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1601.         if (isset($config['prefix_seed'])) {
  1602.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1603.         }
  1604.         if ($container->hasParameter('cache.prefix.seed')) {
  1605.             // Inline any env vars referenced in the parameter
  1606.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1607.         }
  1608.         foreach (['doctrine''psr6''redis''memcached''pdo'] as $name) {
  1609.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1610.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1611.             }
  1612.         }
  1613.         foreach (['app''system'] as $name) {
  1614.             $config['pools']['cache.'.$name] = [
  1615.                 'adapters' => [$config[$name]],
  1616.                 'public' => true,
  1617.                 'tags' => false,
  1618.             ];
  1619.         }
  1620.         foreach ($config['pools'] as $name => $pool) {
  1621.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1622.             foreach ($pool['adapters'] as $provider => $adapter) {
  1623.                 if ($config['pools'][$adapter]['tags'] ?? false) {
  1624.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1625.                 }
  1626.             }
  1627.             if (=== \count($pool['adapters'])) {
  1628.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1629.                     $pool['provider'] = $provider;
  1630.                 }
  1631.                 $definition = new ChildDefinition($adapter);
  1632.             } else {
  1633.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1634.                 $pool['reset'] = 'reset';
  1635.             }
  1636.             if ($pool['tags']) {
  1637.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1638.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1639.                 }
  1640.                 $container->register($nameTagAwareAdapter::class)
  1641.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1642.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1643.                     ->setPublic($pool['public'])
  1644.                 ;
  1645.                 if (method_exists(TagAwareAdapter::class, 'setLogger')) {
  1646.                     $container
  1647.                         ->getDefinition($name)
  1648.                         ->addMethodCall('setLogger', [new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1649.                 }
  1650.                 $pool['name'] = $name;
  1651.                 $pool['public'] = false;
  1652.                 $name '.'.$name.'.inner';
  1653.                 if (!\in_array($pool['name'], ['cache.app''cache.system'], true)) {
  1654.                     $container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
  1655.                     $container->registerAliasForArgument($nameCacheInterface::class, $pool['name']);
  1656.                     $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name']);
  1657.                 }
  1658.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1659.                 $container->register('.'.$name.'.taggable'TagAwareAdapter::class)
  1660.                     ->addArgument(new Reference($name))
  1661.                 ;
  1662.                 $container->registerAliasForArgument('.'.$name.'.taggable'TagAwareCacheInterface::class, $name);
  1663.                 $container->registerAliasForArgument($nameCacheInterface::class);
  1664.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class);
  1665.             }
  1666.             $definition->setPublic($pool['public']);
  1667.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1668.             $definition->addTag('cache.pool'$pool);
  1669.             $container->setDefinition($name$definition);
  1670.         }
  1671.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1672.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1673.             $propertyAccessDefinition->setPublic(false);
  1674.             if (!$container->getParameter('kernel.debug')) {
  1675.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1676.                 $propertyAccessDefinition->setArguments([''0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1677.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1678.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1679.             } else {
  1680.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1681.                 $propertyAccessDefinition->setArguments([0false]);
  1682.             }
  1683.         }
  1684.     }
  1685.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $profilerConfig)
  1686.     {
  1687.         $loader->load('http_client.xml');
  1688.         $container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
  1689.         if (!$hasPsr18 interface_exists(ClientInterface::class)) {
  1690.             $container->removeDefinition('psr18.http_client');
  1691.             $container->removeAlias(ClientInterface::class);
  1692.         }
  1693.         if (!interface_exists(HttpClient::class)) {
  1694.             $container->removeDefinition(HttpClient::class);
  1695.         }
  1696.         $httpClientId $this->isConfigEnabled($container$profilerConfig) ? '.debug.http_client.inner' 'http_client';
  1697.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1698.             if ('http_client' === $name) {
  1699.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1700.             }
  1701.             $scope $scopeConfig['scope'] ?? null;
  1702.             unset($scopeConfig['scope']);
  1703.             if (null === $scope) {
  1704.                 $baseUri $scopeConfig['base_uri'];
  1705.                 unset($scopeConfig['base_uri']);
  1706.                 $container->register($nameScopingHttpClient::class)
  1707.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1708.                     ->setArguments([new Reference($httpClientId), $baseUri$scopeConfig])
  1709.                     ->addTag('http_client.client')
  1710.                 ;
  1711.             } else {
  1712.                 $container->register($nameScopingHttpClient::class)
  1713.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1714.                     ->addTag('http_client.client')
  1715.                 ;
  1716.             }
  1717.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  1718.             if ($hasPsr18) {
  1719.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  1720.                     ->replaceArgument(0, new Reference($name));
  1721.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  1722.             }
  1723.         }
  1724.     }
  1725.     private function registerMailerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1726.     {
  1727.         if (!class_exists(Mailer::class)) {
  1728.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  1729.         }
  1730.         $loader->load('mailer.xml');
  1731.         $loader->load('mailer_transports.xml');
  1732.         if (!\count($config['transports']) && null === $config['dsn']) {
  1733.             $config['dsn'] = 'smtp://null';
  1734.         }
  1735.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  1736.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  1737.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  1738.         $classToServices = [
  1739.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  1740.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  1741.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  1742.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  1743.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  1744.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  1745.         ];
  1746.         foreach ($classToServices as $class => $service) {
  1747.             if (!class_exists($class)) {
  1748.                 $container->removeDefinition($service);
  1749.             }
  1750.         }
  1751.         $recipients $config['envelope']['recipients'] ?? null;
  1752.         $sender $config['envelope']['sender'] ?? null;
  1753.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  1754.         $envelopeListener->setArgument(0$sender);
  1755.         $envelopeListener->setArgument(1$recipients);
  1756.     }
  1757.     /**
  1758.      * {@inheritdoc}
  1759.      */
  1760.     public function getXsdValidationBasePath()
  1761.     {
  1762.         return \dirname(__DIR__).'/Resources/config/schema';
  1763.     }
  1764.     public function getNamespace()
  1765.     {
  1766.         return 'http://symfony.com/schema/dic/symfony';
  1767.     }
  1768. }