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

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