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

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