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

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