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

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.             $finder Finder::create()
  1054.                 ->followLinks()
  1055.                 ->files()
  1056.                 ->filter(function (\SplFileInfo $file) {
  1057.                     return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  1058.                 })
  1059.                 ->in($dirs)
  1060.                 ->sortByName()
  1061.             ;
  1062.             foreach ($finder as $file) {
  1063.                 $fileNameParts explode('.'basename($file));
  1064.                 $locale $fileNameParts[\count($fileNameParts) - 2];
  1065.                 if (!isset($files[$locale])) {
  1066.                     $files[$locale] = [];
  1067.                 }
  1068.                 $files[$locale][] = (string) $file;
  1069.             }
  1070.             $projectDir $container->getParameter('kernel.project_dir');
  1071.             $options array_merge(
  1072.                 $translator->getArgument(4),
  1073.                 [
  1074.                     'resource_files' => $files,
  1075.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1076.                     'cache_vary' => [
  1077.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1078.                             return === strpos($dir$projectDir.'/') ? substr($dir+ \strlen($projectDir)) : $dir;
  1079.                         }, $scannedDirectories),
  1080.                     ],
  1081.                 ]
  1082.             );
  1083.             $translator->replaceArgument(4$options);
  1084.         }
  1085.     }
  1086.     private function registerValidationConfiguration(array $configContainerBuilder $containerXmlFileLoader $loaderbool $propertyInfoEnabled)
  1087.     {
  1088.         if (!$this->validatorConfigEnabled $this->isConfigEnabled($container$config)) {
  1089.             return;
  1090.         }
  1091.         if (!class_exists(\Symfony\Component\Validator\Validation::class)) {
  1092.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1093.         }
  1094.         if (!isset($config['email_validation_mode'])) {
  1095.             $config['email_validation_mode'] = 'loose';
  1096.         }
  1097.         $loader->load('validator.xml');
  1098.         $validatorBuilder $container->getDefinition('validator.builder');
  1099.         if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
  1100.             $calls $validatorBuilder->getMethodCalls();
  1101.             $calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])]];
  1102.             $validatorBuilder->setMethodCalls($calls);
  1103.         }
  1104.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1105.         $files = ['xml' => [], 'yml' => []];
  1106.         $this->registerValidatorMapping($container$config$files);
  1107.         if (!empty($files['xml'])) {
  1108.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1109.         }
  1110.         if (!empty($files['yml'])) {
  1111.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1112.         }
  1113.         $definition $container->findDefinition('validator.email');
  1114.         $definition->replaceArgument(0$config['email_validation_mode']);
  1115.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1116.             if (!$this->annotationsConfigEnabled) {
  1117.                 throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
  1118.             }
  1119.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
  1120.         }
  1121.         if (\array_key_exists('static_method'$config) && $config['static_method']) {
  1122.             foreach ($config['static_method'] as $methodName) {
  1123.                 $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
  1124.             }
  1125.         }
  1126.         if (!$container->getParameter('kernel.debug')) {
  1127.             $validatorBuilder->addMethodCall('setMappingCache', [new Reference('validator.mapping.cache.adapter')]);
  1128.         }
  1129.         $container->setParameter('validator.auto_mapping'$config['auto_mapping']);
  1130.         if (!$propertyInfoEnabled || !class_exists(PropertyInfoLoader::class)) {
  1131.             $container->removeDefinition('validator.property_info_loader');
  1132.         }
  1133.         $container
  1134.             ->getDefinition('validator.not_compromised_password')
  1135.             ->setArgument(2$config['not_compromised_password']['enabled'])
  1136.             ->setArgument(3$config['not_compromised_password']['endpoint'])
  1137.         ;
  1138.     }
  1139.     private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files)
  1140.     {
  1141.         $fileRecorder = function ($extension$path) use (&$files) {
  1142.             $files['yaml' === $extension 'yml' $extension][] = $path;
  1143.         };
  1144.         if (interface_exists(\Symfony\Component\Form\FormInterface::class)) {
  1145.             $reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class);
  1146.             $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
  1147.         }
  1148.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1149.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1150.             if (
  1151.                 $container->fileExists($file $configDir.'/validation.yaml'false) ||
  1152.                 $container->fileExists($file $configDir.'/validation.yml'false)
  1153.             ) {
  1154.                 $fileRecorder('yml'$file);
  1155.             }
  1156.             if ($container->fileExists($file $configDir.'/validation.xml'false)) {
  1157.                 $fileRecorder('xml'$file);
  1158.             }
  1159.             if ($container->fileExists($dir $configDir.'/validation''/^$/')) {
  1160.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1161.             }
  1162.         }
  1163.         $projectDir $container->getParameter('kernel.project_dir');
  1164.         if ($container->fileExists($dir $projectDir.'/config/validator''/^$/')) {
  1165.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1166.         }
  1167.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1168.     }
  1169.     private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
  1170.     {
  1171.         foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
  1172.             $fileRecorder($file->getExtension(), $file->getRealPath());
  1173.         }
  1174.     }
  1175.     private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder)
  1176.     {
  1177.         foreach ($config['mapping']['paths'] as $path) {
  1178.             if (is_dir($path)) {
  1179.                 $this->registerMappingFilesFromDir($path$fileRecorder);
  1180.                 $container->addResource(new DirectoryResource($path'/^$/'));
  1181.             } elseif ($container->fileExists($pathfalse)) {
  1182.                 if (!preg_match('/\.(xml|ya?ml)$/'$path$matches)) {
  1183.                     throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.'$path));
  1184.                 }
  1185.                 $fileRecorder($matches[1], $path);
  1186.             } else {
  1187.                 throw new \RuntimeException(sprintf('Could not open file or directory "%s".'$path));
  1188.             }
  1189.         }
  1190.     }
  1191.     private function registerAnnotationsConfiguration(array $configContainerBuilder $containerLoaderInterface $loader)
  1192.     {
  1193.         if (!$this->annotationsConfigEnabled) {
  1194.             return;
  1195.         }
  1196.         if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
  1197.             throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
  1198.         }
  1199.         $loader->load('annotations.xml');
  1200.         if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  1201.             $container->getDefinition('annotations.dummy_registry')
  1202.                 ->setMethodCalls([['registerLoader', ['class_exists']]]);
  1203.         }
  1204.         if ('none' !== $config['cache']) {
  1205.             if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
  1206.                 throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
  1207.             }
  1208.             $cacheService $config['cache'];
  1209.             if ('php_array' === $config['cache']) {
  1210.                 $cacheService 'annotations.cache';
  1211.                 // Enable warmer only if PHP array is used for cache
  1212.                 $definition $container->findDefinition('annotations.cache_warmer');
  1213.                 $definition->addTag('kernel.cache_warmer');
  1214.             } elseif ('file' === $config['cache']) {
  1215.                 $cacheDir $container->getParameterBag()->resolveValue($config['file_cache_dir']);
  1216.                 if (!is_dir($cacheDir) && false === @mkdir($cacheDir0777true) && !is_dir($cacheDir)) {
  1217.                     throw new \RuntimeException(sprintf('Could not create cache directory "%s".'$cacheDir));
  1218.                 }
  1219.                 $container
  1220.                     ->getDefinition('annotations.filesystem_cache')
  1221.                     ->replaceArgument(0$cacheDir)
  1222.                 ;
  1223.                 $cacheService 'annotations.filesystem_cache';
  1224.             }
  1225.             $container
  1226.                 ->getDefinition('annotations.cached_reader')
  1227.                 ->replaceArgument(2$config['debug'])
  1228.                 // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
  1229.                 ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
  1230.                 ->addTag('annotations.cached_reader')
  1231.             ;
  1232.             $container->setAlias('annotation_reader''annotations.cached_reader')->setPrivate(true);
  1233.             $container->setAlias(Reader::class, new Alias('annotations.cached_reader'false));
  1234.         } else {
  1235.             $container->removeDefinition('annotations.cached_reader');
  1236.         }
  1237.     }
  1238.     private function registerPropertyAccessConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1239.     {
  1240.         if (!class_exists(PropertyAccessor::class)) {
  1241.             return;
  1242.         }
  1243.         $loader->load('property_access.xml');
  1244.         $container
  1245.             ->getDefinition('property_accessor')
  1246.             ->replaceArgument(0$config['magic_call'])
  1247.             ->replaceArgument(1$config['throw_exception_on_invalid_index'])
  1248.             ->replaceArgument(3$config['throw_exception_on_invalid_property_path'])
  1249.         ;
  1250.     }
  1251.     private function registerSecretsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1252.     {
  1253.         if (!$this->isConfigEnabled($container$config)) {
  1254.             $container->removeDefinition('console.command.secrets_set');
  1255.             $container->removeDefinition('console.command.secrets_list');
  1256.             $container->removeDefinition('console.command.secrets_remove');
  1257.             $container->removeDefinition('console.command.secrets_generate_key');
  1258.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1259.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1260.             return;
  1261.         }
  1262.         $loader->load('secrets.xml');
  1263.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1264.         if ($config['local_dotenv_file']) {
  1265.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1266.         } else {
  1267.             $container->removeDefinition('secrets.local_vault');
  1268.         }
  1269.         if ($config['decryption_env_var']) {
  1270.             if (!preg_match('/^(?:\w*+:)*+\w++$/'$config['decryption_env_var'])) {
  1271.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1272.             }
  1273.             $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1274.         } else {
  1275.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1276.         }
  1277.     }
  1278.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1279.     {
  1280.         if (!$this->isConfigEnabled($container$config)) {
  1281.             return;
  1282.         }
  1283.         if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
  1284.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1285.         }
  1286.         if (!$this->sessionConfigEnabled) {
  1287.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1288.         }
  1289.         // Enable services for CSRF protection (even without forms)
  1290.         $loader->load('security_csrf.xml');
  1291.         if (!class_exists(CsrfExtension::class)) {
  1292.             $container->removeDefinition('twig.extension.security_csrf');
  1293.         }
  1294.     }
  1295.     private function registerSerializerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1296.     {
  1297.         $loader->load('serializer.xml');
  1298.         if (!class_exists(ConstraintViolationListNormalizer::class)) {
  1299.             $container->removeDefinition('serializer.normalizer.constraint_violation_list');
  1300.         }
  1301.         if (!class_exists(ClassDiscriminatorFromClassMetadata::class)) {
  1302.             $container->removeAlias('Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface');
  1303.             $container->removeDefinition('serializer.mapping.class_discriminator_resolver');
  1304.         }
  1305.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1306.         if (!class_exists(PropertyAccessor::class)) {
  1307.             $container->removeAlias('serializer.property_accessor');
  1308.             $container->removeDefinition('serializer.normalizer.object');
  1309.         }
  1310.         if (!class_exists(Yaml::class)) {
  1311.             $container->removeDefinition('serializer.encoder.yaml');
  1312.         }
  1313.         $serializerLoaders = [];
  1314.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1315.             if (!$this->annotationsConfigEnabled) {
  1316.                 throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
  1317.             }
  1318.             $annotationLoader = new Definition(
  1319.                 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
  1320.                 [new Reference('annotation_reader')]
  1321.             );
  1322.             $annotationLoader->setPublic(false);
  1323.             $serializerLoaders[] = $annotationLoader;
  1324.         }
  1325.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1326.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
  1327.             $definition->setPublic(false);
  1328.             $serializerLoaders[] = $definition;
  1329.         };
  1330.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1331.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1332.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1333.                 $fileRecorder('xml'$file);
  1334.             }
  1335.             if (
  1336.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1337.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1338.             ) {
  1339.                 $fileRecorder('yml'$file);
  1340.             }
  1341.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1342.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1343.             }
  1344.         }
  1345.         $projectDir $container->getParameter('kernel.project_dir');
  1346.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1347.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1348.         }
  1349.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1350.         $chainLoader->replaceArgument(0$serializerLoaders);
  1351.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1352.         if ($container->getParameter('kernel.debug')) {
  1353.             $container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
  1354.         }
  1355.         if (isset($config['name_converter']) && $config['name_converter']) {
  1356.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1357.         }
  1358.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1359.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1360.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1361.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1362.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1363.         }
  1364.         if ($config['max_depth_handler'] ?? false) {
  1365.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1366.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1367.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1368.         }
  1369.     }
  1370.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerXmlFileLoader $loader)
  1371.     {
  1372.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1373.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1374.         }
  1375.         $loader->load('property_info.xml');
  1376.         if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) {
  1377.             $definition $container->register('property_info.php_doc_extractor''Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
  1378.             $definition->setPrivate(true);
  1379.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1380.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1381.         }
  1382.         if ($container->getParameter('kernel.debug')) {
  1383.             $container->removeDefinition('property_info.cache');
  1384.         }
  1385.     }
  1386.     private function registerLockConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1387.     {
  1388.         $loader->load('lock.xml');
  1389.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1390.             if (=== \count($resourceStores)) {
  1391.                 continue;
  1392.             }
  1393.             // Generate stores
  1394.             $storeDefinitions = [];
  1395.             foreach ($resourceStores as $storeDsn) {
  1396.                 $storeDsn $container->resolveEnvPlaceholders($storeDsnnull$usedEnvs);
  1397.                 $storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class);
  1398.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1399.                 $storeDefinition->setArguments([$storeDsn]);
  1400.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1401.                 $storeDefinition = new Reference($storeDefinitionId);
  1402.                 $storeDefinitions[] = $storeDefinition;
  1403.             }
  1404.             // Wrap array of stores with CombinedStore
  1405.             if (\count($storeDefinitions) > 1) {
  1406.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1407.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1408.                 $container->setDefinition('lock.'.$resourceName.'.store'$combinedDefinition);
  1409.             } else {
  1410.                 $container->setAlias('lock.'.$resourceName.'.store', new Alias((string) $storeDefinitions[0], false));
  1411.             }
  1412.             // Generate factories for each resource
  1413.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1414.             $factoryDefinition->replaceArgument(0, new Reference('lock.'.$resourceName.'.store'));
  1415.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1416.             // Generate services for lock instances
  1417.             $lockDefinition = new Definition(Lock::class);
  1418.             $lockDefinition->setPublic(false);
  1419.             $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
  1420.             $lockDefinition->setArguments([$resourceName]);
  1421.             $container->setDefinition('lock.'.$resourceName$lockDefinition);
  1422.             // provide alias for default resource
  1423.             if ('default' === $resourceName) {
  1424.                 $container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store'false));
  1425.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1426.                 $container->setAlias('lock', new Alias('lock.'.$resourceNamefalse));
  1427.                 $container->setAlias(StoreInterface::class, new Alias('lock.store'false));
  1428.                 $container->setAlias(PersistingStoreInterface::class, new Alias('lock.store'false));
  1429.                 $container->setAlias(Factory::class, new Alias('lock.factory'false));
  1430.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1431.                 $container->setAlias(LockInterface::class, new Alias('lock'false));
  1432.             } else {
  1433.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'StoreInterface::class, $resourceName.'.lock.store');
  1434.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'PersistingStoreInterface::class, $resourceName.'.lock.store');
  1435.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'Factory::class, $resourceName.'.lock.factory');
  1436.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1437.                 $container->registerAliasForArgument('lock.'.$resourceNameLockInterface::class, $resourceName.'.lock');
  1438.             }
  1439.         }
  1440.     }
  1441.     private function registerMessengerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $validationConfig)
  1442.     {
  1443.         if (!interface_exists(MessageBusInterface::class)) {
  1444.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1445.         }
  1446.         $loader->load('messenger.xml');
  1447.         if (class_exists(AmqpTransportFactory::class)) {
  1448.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1449.         }
  1450.         if (class_exists(RedisTransportFactory::class)) {
  1451.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1452.         }
  1453.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1454.             $config['default_bus'] = key($config['buses']);
  1455.         }
  1456.         $defaultMiddleware = [
  1457.             'before' => [
  1458.                 ['id' => 'add_bus_name_stamp_middleware'],
  1459.                 ['id' => 'reject_redelivered_message_middleware'],
  1460.                 ['id' => 'dispatch_after_current_bus'],
  1461.                 ['id' => 'failed_message_processing_middleware'],
  1462.             ],
  1463.             'after' => [
  1464.                 ['id' => 'send_message'],
  1465.                 ['id' => 'handle_message'],
  1466.             ],
  1467.         ];
  1468.         foreach ($config['buses'] as $busId => $bus) {
  1469.             $middleware $bus['middleware'];
  1470.             if ($bus['default_middleware']) {
  1471.                 if ('allow_no_handlers' === $bus['default_middleware']) {
  1472.                     $defaultMiddleware['after'][1]['arguments'] = [true];
  1473.                 } else {
  1474.                     unset($defaultMiddleware['after'][1]['arguments']);
  1475.                 }
  1476.                 // argument to add_bus_name_stamp_middleware
  1477.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1478.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1479.             }
  1480.             foreach ($middleware as $middlewareItem) {
  1481.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1482.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1483.                 }
  1484.             }
  1485.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1486.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1487.             }
  1488.             $container->setParameter($busId.'.middleware'$middleware);
  1489.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1490.             if ($busId === $config['default_bus']) {
  1491.                 $container->setAlias('message_bus'$busId)->setPublic(true)->setDeprecated(true'The "%alias_id%" service is deprecated, use the "messenger.default_bus" service instead.');
  1492.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1493.                 $container->setAlias(MessageBusInterface::class, $busId);
  1494.             } else {
  1495.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1496.             }
  1497.         }
  1498.         if (empty($config['transports'])) {
  1499.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1500.             $container->removeDefinition('messenger.transport.amqp.factory');
  1501.             $container->removeDefinition('messenger.transport.redis.factory');
  1502.         } else {
  1503.             $container->getDefinition('messenger.transport.symfony_serializer')
  1504.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1505.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1506.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1507.         }
  1508.         $senderAliases = [];
  1509.         $transportRetryReferences = [];
  1510.         foreach ($config['transports'] as $name => $transport) {
  1511.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1512.             $transportDefinition = (new Definition(TransportInterface::class))
  1513.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1514.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1515.                 ->addTag('messenger.receiver', ['alias' => $name])
  1516.             ;
  1517.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1518.             $senderAliases[$name] = $transportId;
  1519.             if (null !== $transport['retry_strategy']['service']) {
  1520.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1521.             } else {
  1522.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1523.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1524.                 $retryDefinition
  1525.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1526.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1527.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1528.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1529.                 $container->setDefinition($retryServiceId$retryDefinition);
  1530.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1531.             }
  1532.         }
  1533.         $senderReferences = [];
  1534.         // alias => service_id
  1535.         foreach ($senderAliases as $alias => $serviceId) {
  1536.             $senderReferences[$alias] = new Reference($serviceId);
  1537.         }
  1538.         // service_id => service_id
  1539.         foreach ($senderAliases as $serviceId) {
  1540.             $senderReferences[$serviceId] = new Reference($serviceId);
  1541.         }
  1542.         $messageToSendersMapping = [];
  1543.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1544.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1545.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1546.             }
  1547.             // make sure senderAliases contains all senders
  1548.             foreach ($messageConfiguration['senders'] as $sender) {
  1549.                 if (!isset($senderReferences[$sender])) {
  1550.                     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));
  1551.                 }
  1552.             }
  1553.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1554.         }
  1555.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1556.         $container->getDefinition('messenger.senders_locator')
  1557.             ->replaceArgument(0$messageToSendersMapping)
  1558.             ->replaceArgument(1$sendersServiceLocator)
  1559.         ;
  1560.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1561.             ->replaceArgument(0$sendersServiceLocator)
  1562.         ;
  1563.         $container->getDefinition('messenger.retry_strategy_locator')
  1564.             ->replaceArgument(0$transportRetryReferences);
  1565.         if ($config['failure_transport']) {
  1566.             if (!isset($senderReferences[$config['failure_transport']])) {
  1567.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1568.             }
  1569.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1570.                 ->replaceArgument(0$senderReferences[$config['failure_transport']]);
  1571.             $container->getDefinition('console.command.messenger_failed_messages_retry')
  1572.                 ->replaceArgument(0$config['failure_transport']);
  1573.             $container->getDefinition('console.command.messenger_failed_messages_show')
  1574.                 ->replaceArgument(0$config['failure_transport']);
  1575.             $container->getDefinition('console.command.messenger_failed_messages_remove')
  1576.                 ->replaceArgument(0$config['failure_transport']);
  1577.         } else {
  1578.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1579.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1580.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1581.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1582.         }
  1583.     }
  1584.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1585.     {
  1586.         if (!class_exists(DefaultMarshaller::class)) {
  1587.             $container->removeDefinition('cache.default_marshaller');
  1588.         }
  1589.         $version = new Parameter('container.build_id');
  1590.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1591.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1592.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1593.         if (isset($config['prefix_seed'])) {
  1594.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1595.         }
  1596.         if ($container->hasParameter('cache.prefix.seed')) {
  1597.             // Inline any env vars referenced in the parameter
  1598.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1599.         }
  1600.         foreach (['doctrine''psr6''redis''memcached''pdo'] as $name) {
  1601.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1602.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1603.             }
  1604.         }
  1605.         foreach (['app''system'] as $name) {
  1606.             $config['pools']['cache.'.$name] = [
  1607.                 'adapters' => [$config[$name]],
  1608.                 'public' => true,
  1609.                 'tags' => false,
  1610.             ];
  1611.         }
  1612.         foreach ($config['pools'] as $name => $pool) {
  1613.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1614.             foreach ($pool['adapters'] as $provider => $adapter) {
  1615.                 if ($config['pools'][$adapter]['tags'] ?? false) {
  1616.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1617.                 }
  1618.             }
  1619.             if (=== \count($pool['adapters'])) {
  1620.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1621.                     $pool['provider'] = $provider;
  1622.                 }
  1623.                 $definition = new ChildDefinition($adapter);
  1624.             } else {
  1625.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1626.                 $pool['reset'] = 'reset';
  1627.             }
  1628.             if ($pool['tags']) {
  1629.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1630.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1631.                 }
  1632.                 $container->register($nameTagAwareAdapter::class)
  1633.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1634.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1635.                     ->setPublic($pool['public'])
  1636.                 ;
  1637.                 $pool['name'] = $name;
  1638.                 $pool['public'] = false;
  1639.                 $name '.'.$name.'.inner';
  1640.                 if (!\in_array($pool['name'], ['cache.app''cache.system'], true)) {
  1641.                     $container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
  1642.                     $container->registerAliasForArgument($nameCacheInterface::class, $pool['name']);
  1643.                     $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name']);
  1644.                 }
  1645.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1646.                 $container->register('.'.$name.'.taggable'TagAwareAdapter::class)
  1647.                     ->addArgument(new Reference($name))
  1648.                 ;
  1649.                 $container->registerAliasForArgument('.'.$name.'.taggable'TagAwareCacheInterface::class, $name);
  1650.                 $container->registerAliasForArgument($nameCacheInterface::class);
  1651.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class);
  1652.             }
  1653.             $definition->setPublic($pool['public']);
  1654.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1655.             $definition->addTag('cache.pool'$pool);
  1656.             $container->setDefinition($name$definition);
  1657.         }
  1658.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1659.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1660.             $propertyAccessDefinition->setPublic(false);
  1661.             if (!$container->getParameter('kernel.debug')) {
  1662.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1663.                 $propertyAccessDefinition->setArguments([null0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1664.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1665.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1666.             } else {
  1667.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1668.                 $propertyAccessDefinition->setArguments([0false]);
  1669.             }
  1670.         }
  1671.     }
  1672.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $profilerConfig)
  1673.     {
  1674.         $loader->load('http_client.xml');
  1675.         $container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
  1676.         if (!$hasPsr18 interface_exists(ClientInterface::class)) {
  1677.             $container->removeDefinition('psr18.http_client');
  1678.             $container->removeAlias(ClientInterface::class);
  1679.         }
  1680.         if (!interface_exists(HttpClient::class)) {
  1681.             $container->removeDefinition(HttpClient::class);
  1682.         }
  1683.         $httpClientId $this->isConfigEnabled($container$profilerConfig) ? '.debug.http_client.inner' 'http_client';
  1684.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1685.             if ('http_client' === $name) {
  1686.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1687.             }
  1688.             $scope $scopeConfig['scope'] ?? null;
  1689.             unset($scopeConfig['scope']);
  1690.             if (null === $scope) {
  1691.                 $baseUri $scopeConfig['base_uri'];
  1692.                 unset($scopeConfig['base_uri']);
  1693.                 $container->register($nameScopingHttpClient::class)
  1694.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1695.                     ->setArguments([new Reference($httpClientId), $baseUri$scopeConfig])
  1696.                     ->addTag('http_client.client')
  1697.                 ;
  1698.             } else {
  1699.                 $container->register($nameScopingHttpClient::class)
  1700.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1701.                     ->addTag('http_client.client')
  1702.                 ;
  1703.             }
  1704.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  1705.             if ($hasPsr18) {
  1706.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  1707.                     ->replaceArgument(0, new Reference($name));
  1708.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  1709.             }
  1710.         }
  1711.     }
  1712.     private function registerMailerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1713.     {
  1714.         if (!class_exists(Mailer::class)) {
  1715.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  1716.         }
  1717.         $loader->load('mailer.xml');
  1718.         $loader->load('mailer_transports.xml');
  1719.         if (!\count($config['transports']) && null === $config['dsn']) {
  1720.             $config['dsn'] = 'smtp://null';
  1721.         }
  1722.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  1723.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  1724.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  1725.         $classToServices = [
  1726.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  1727.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  1728.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  1729.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  1730.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  1731.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  1732.         ];
  1733.         foreach ($classToServices as $class => $service) {
  1734.             if (!class_exists($class)) {
  1735.                 $container->removeDefinition($service);
  1736.             }
  1737.         }
  1738.         $recipients $config['envelope']['recipients'] ?? null;
  1739.         $sender $config['envelope']['sender'] ?? null;
  1740.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  1741.         $envelopeListener->setArgument(0$sender);
  1742.         $envelopeListener->setArgument(1$recipients);
  1743.     }
  1744.     /**
  1745.      * {@inheritdoc}
  1746.      */
  1747.     public function getXsdValidationBasePath()
  1748.     {
  1749.         return \dirname(__DIR__).'/Resources/config/schema';
  1750.     }
  1751.     public function getNamespace()
  1752.     {
  1753.         return 'http://symfony.com/schema/dic/symfony';
  1754.     }
  1755. }