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

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\RouteLoaderInterface;
  24. use Symfony\Bundle\FullStack;
  25. use Symfony\Component\Asset\PackageInterface;
  26. use Symfony\Component\BrowserKit\AbstractBrowser;
  27. use Symfony\Component\Cache\Adapter\AdapterInterface;
  28. use Symfony\Component\Cache\Adapter\ArrayAdapter;
  29. use Symfony\Component\Cache\Adapter\ChainAdapter;
  30. use Symfony\Component\Cache\Adapter\TagAwareAdapter;
  31. use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
  32. use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
  33. use Symfony\Component\Cache\Marshaller\MarshallerInterface;
  34. use Symfony\Component\Cache\ResettableInterface;
  35. use Symfony\Component\Config\FileLocator;
  36. use Symfony\Component\Config\Loader\LoaderInterface;
  37. use Symfony\Component\Config\Resource\DirectoryResource;
  38. use Symfony\Component\Config\ResourceCheckerInterface;
  39. use Symfony\Component\Console\Application;
  40. use Symfony\Component\Console\Command\Command;
  41. use Symfony\Component\DependencyInjection\Alias;
  42. use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  43. use Symfony\Component\DependencyInjection\ChildDefinition;
  44. use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
  45. use Symfony\Component\DependencyInjection\ContainerBuilder;
  46. use Symfony\Component\DependencyInjection\ContainerInterface;
  47. use Symfony\Component\DependencyInjection\Definition;
  48. use Symfony\Component\DependencyInjection\EnvVarLoaderInterface;
  49. use Symfony\Component\DependencyInjection\EnvVarProcessorInterface;
  50. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  51. use Symfony\Component\DependencyInjection\Exception\LogicException;
  52. use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
  53. use Symfony\Component\DependencyInjection\Parameter;
  54. use Symfony\Component\DependencyInjection\Reference;
  55. use Symfony\Component\DependencyInjection\ServiceLocator;
  56. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  57. use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
  58. use Symfony\Component\Finder\Finder;
  59. use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
  60. use Symfony\Component\Form\FormTypeExtensionInterface;
  61. use Symfony\Component\Form\FormTypeGuesserInterface;
  62. use Symfony\Component\Form\FormTypeInterface;
  63. use Symfony\Component\HttpClient\MockHttpClient;
  64. use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
  65. use Symfony\Component\HttpClient\RetryableHttpClient;
  66. use Symfony\Component\HttpClient\ScopingHttpClient;
  67. use Symfony\Component\HttpFoundation\Request;
  68. use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
  69. use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
  70. use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
  71. use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
  72. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  73. use Symfony\Component\Lock\Lock;
  74. use Symfony\Component\Lock\LockFactory;
  75. use Symfony\Component\Lock\LockInterface;
  76. use Symfony\Component\Lock\PersistingStoreInterface;
  77. use Symfony\Component\Lock\Store\StoreFactory;
  78. use Symfony\Component\Lock\StoreInterface;
  79. use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
  80. use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
  81. use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
  82. use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory;
  83. use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory;
  84. use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory;
  85. use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory;
  86. use Symfony\Component\Mailer\Bridge\Sendinblue\Transport\SendinblueTransportFactory;
  87. use Symfony\Component\Mailer\Mailer;
  88. use Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\AmazonSqsTransportFactory;
  89. use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpTransportFactory;
  90. use Symfony\Component\Messenger\Bridge\Beanstalkd\Transport\BeanstalkdTransportFactory;
  91. use Symfony\Component\Messenger\Bridge\Redis\Transport\RedisTransportFactory;
  92. use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
  93. use Symfony\Component\Messenger\MessageBus;
  94. use Symfony\Component\Messenger\MessageBusInterface;
  95. use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
  96. use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
  97. use Symfony\Component\Messenger\Transport\TransportInterface;
  98. use Symfony\Component\Mime\Header\Headers;
  99. use Symfony\Component\Mime\MimeTypeGuesserInterface;
  100. use Symfony\Component\Mime\MimeTypes;
  101. use Symfony\Component\Notifier\Bridge\Discord\DiscordTransportFactory;
  102. use Symfony\Component\Notifier\Bridge\Esendex\EsendexTransportFactory;
  103. use Symfony\Component\Notifier\Bridge\Firebase\FirebaseTransportFactory;
  104. use Symfony\Component\Notifier\Bridge\FreeMobile\FreeMobileTransportFactory;
  105. use Symfony\Component\Notifier\Bridge\GoogleChat\GoogleChatTransportFactory;
  106. use Symfony\Component\Notifier\Bridge\Infobip\InfobipTransportFactory;
  107. use Symfony\Component\Notifier\Bridge\LinkedIn\LinkedInTransportFactory;
  108. use Symfony\Component\Notifier\Bridge\Mattermost\MattermostTransportFactory;
  109. use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory;
  110. use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory;
  111. use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransportFactory;
  112. use Symfony\Component\Notifier\Bridge\RocketChat\RocketChatTransportFactory;
  113. use Symfony\Component\Notifier\Bridge\Sendinblue\SendinblueTransportFactory as SendinblueNotifierTransportFactory;
  114. use Symfony\Component\Notifier\Bridge\Sinch\SinchTransportFactory;
  115. use Symfony\Component\Notifier\Bridge\Slack\SlackTransportFactory;
  116. use Symfony\Component\Notifier\Bridge\Smsapi\SmsapiTransportFactory;
  117. use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransportFactory;
  118. use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory;
  119. use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory;
  120. use Symfony\Component\Notifier\Notifier;
  121. use Symfony\Component\Notifier\Recipient\Recipient;
  122. use Symfony\Component\PropertyAccess\PropertyAccessor;
  123. use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
  124. use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface;
  125. use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
  126. use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface;
  127. use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
  128. use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
  129. use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
  130. use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;
  131. use Symfony\Component\RateLimiter\LimiterInterface;
  132. use Symfony\Component\RateLimiter\RateLimiterFactory;
  133. use Symfony\Component\RateLimiter\Storage\CacheStorage;
  134. use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
  135. use Symfony\Component\Routing\Loader\AnnotationFileLoader;
  136. use Symfony\Component\Security\Core\Security;
  137. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  138. use Symfony\Component\Serializer\Encoder\DecoderInterface;
  139. use Symfony\Component\Serializer\Encoder\EncoderInterface;
  140. use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  141. use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  142. use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
  143. use Symfony\Component\Stopwatch\Stopwatch;
  144. use Symfony\Component\String\LazyString;
  145. use Symfony\Component\String\Slugger\SluggerInterface;
  146. use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
  147. use Symfony\Component\Translation\PseudoLocalizationTranslator;
  148. use Symfony\Component\Translation\Translator;
  149. use Symfony\Component\Validator\ConstraintValidatorInterface;
  150. use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
  151. use Symfony\Component\Validator\ObjectInitializerInterface;
  152. use Symfony\Component\WebLink\HttpHeaderSerializer;
  153. use Symfony\Component\Workflow;
  154. use Symfony\Component\Workflow\WorkflowInterface;
  155. use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
  156. use Symfony\Component\Yaml\Yaml;
  157. use Symfony\Contracts\Cache\CacheInterface;
  158. use Symfony\Contracts\Cache\CallbackInterface;
  159. use Symfony\Contracts\Cache\TagAwareCacheInterface;
  160. use Symfony\Contracts\HttpClient\HttpClientInterface;
  161. use Symfony\Contracts\Service\ResetInterface;
  162. use Symfony\Contracts\Service\ServiceSubscriberInterface;
  163. use Symfony\Contracts\Translation\LocaleAwareInterface;
  164. /**
  165.  * FrameworkExtension.
  166.  *
  167.  * @author Fabien Potencier <fabien@symfony.com>
  168.  * @author Jeremy Mikola <jmikola@gmail.com>
  169.  * @author Kévin Dunglas <dunglas@gmail.com>
  170.  * @author Grégoire Pineau <lyrixx@lyrixx.info>
  171.  */
  172. class FrameworkExtension extends Extension
  173. {
  174.     private $formConfigEnabled false;
  175.     private $translationConfigEnabled false;
  176.     private $sessionConfigEnabled false;
  177.     private $annotationsConfigEnabled false;
  178.     private $validatorConfigEnabled false;
  179.     private $messengerConfigEnabled false;
  180.     private $mailerConfigEnabled false;
  181.     private $httpClientConfigEnabled false;
  182.     private $notifierConfigEnabled false;
  183.     private $lockConfigEnabled false;
  184.     /**
  185.      * Responds to the app.config configuration parameter.
  186.      *
  187.      * @throws LogicException
  188.      */
  189.     public function load(array $configsContainerBuilder $container)
  190.     {
  191.         $loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
  192.         $loader->load('web.php');
  193.         $loader->load('services.php');
  194.         $loader->load('fragment_renderer.php');
  195.         $loader->load('error_renderer.php');
  196.         if (interface_exists(PsrEventDispatcherInterface::class)) {
  197.             $container->setAlias(PsrEventDispatcherInterface::class, 'event_dispatcher');
  198.         }
  199.         $container->registerAliasForArgument('parameter_bag'PsrContainerInterface::class);
  200.         if (class_exists(Application::class)) {
  201.             $loader->load('console.php');
  202.             if (!class_exists(BaseXliffLintCommand::class)) {
  203.                 $container->removeDefinition('console.command.xliff_lint');
  204.             }
  205.             if (!class_exists(BaseYamlLintCommand::class)) {
  206.                 $container->removeDefinition('console.command.yaml_lint');
  207.             }
  208.         }
  209.         // Load Cache configuration first as it is used by other components
  210.         $loader->load('cache.php');
  211.         $configuration $this->getConfiguration($configs$container);
  212.         $config $this->processConfiguration($configuration$configs);
  213.         $this->annotationsConfigEnabled $this->isConfigEnabled($container$config['annotations']);
  214.         $this->translationConfigEnabled $this->isConfigEnabled($container$config['translator']);
  215.         // A translator must always be registered (as support is included by
  216.         // default in the Form and Validator component). If disabled, an identity
  217.         // translator will be used and everything will still work as expected.
  218.         if ($this->isConfigEnabled($container$config['translator']) || $this->isConfigEnabled($container$config['form']) || $this->isConfigEnabled($container$config['validation'])) {
  219.             if (!class_exists(Translator::class) && $this->isConfigEnabled($container$config['translator'])) {
  220.                 throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
  221.             }
  222.             if (class_exists(Translator::class)) {
  223.                 $loader->load('identity_translator.php');
  224.             }
  225.         }
  226.         // If the slugger is used but the String component is not available, we should throw an error
  227.         if (!interface_exists(SluggerInterface::class)) {
  228.             $container->register('slugger''stdClass')
  229.                 ->addError('You cannot use the "slugger" service since the String component is not installed. Try running "composer require symfony/string".');
  230.         } else {
  231.             if (!interface_exists(LocaleAwareInterface::class)) {
  232.                 $container->register('slugger''stdClass')
  233.                     ->addError('You cannot use the "slugger" service since the Translation contracts are not installed. Try running "composer require symfony/translation".');
  234.             }
  235.             if (!\extension_loaded('intl') && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
  236.                 trigger_deprecation('''''Please install the "intl" PHP extension for best performance.');
  237.             }
  238.         }
  239.         if (isset($config['secret'])) {
  240.             $container->setParameter('kernel.secret'$config['secret']);
  241.         }
  242.         $container->setParameter('kernel.http_method_override'$config['http_method_override']);
  243.         $container->setParameter('kernel.trusted_hosts'$config['trusted_hosts']);
  244.         $container->setParameter('kernel.default_locale'$config['default_locale']);
  245.         $container->setParameter('kernel.error_controller'$config['error_controller']);
  246.         if (($config['trusted_proxies'] ?? false) && ($config['trusted_headers'] ?? false)) {
  247.             $container->setParameter('kernel.trusted_proxies'$config['trusted_proxies']);
  248.             $container->setParameter('kernel.trusted_headers'$this->resolveTrustedHeaders($config['trusted_headers']));
  249.         }
  250.         if (!$container->hasParameter('debug.file_link_format')) {
  251.             $links = [
  252.                 'textmate' => 'txmt://open?url=file://%%f&line=%%l',
  253.                 'macvim' => 'mvim://open?url=file://%%f&line=%%l',
  254.                 'emacs' => 'emacs://open?url=file://%%f&line=%%l',
  255.                 'sublime' => 'subl://open?url=file://%%f&line=%%l',
  256.                 'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
  257.                 'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
  258.                 'vscode' => 'vscode://file/%%f:%%l',
  259.             ];
  260.             $ide $config['ide'];
  261.             // mark any env vars found in the ide setting as used
  262.             $container->resolveEnvPlaceholders($ide);
  263.             $container->setParameter('debug.file_link_format'str_replace('%''%%'ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: ($links[$ide] ?? $ide));
  264.         }
  265.         if (!empty($config['test'])) {
  266.             $loader->load('test.php');
  267.             if (!class_exists(AbstractBrowser::class)) {
  268.                 $container->removeDefinition('test.client');
  269.             }
  270.         }
  271.         // register cache before session so both can share the connection services
  272.         $this->registerCacheConfiguration($config['cache'], $container);
  273.         if ($this->isConfigEnabled($container$config['session'])) {
  274.             if (!\extension_loaded('session')) {
  275.                 throw new LogicException('Session support cannot be enabled as the session extension is not installed. See https://php.net/session.installation for instructions.');
  276.             }
  277.             $this->sessionConfigEnabled true;
  278.             $this->registerSessionConfiguration($config['session'], $container$loader);
  279.             if (!empty($config['test'])) {
  280.                 $container->getDefinition('test.session.listener')->setArgument(1'%session.storage.options%');
  281.             }
  282.         }
  283.         if ($this->isConfigEnabled($container$config['request'])) {
  284.             $this->registerRequestConfiguration($config['request'], $container$loader);
  285.         }
  286.         if (null === $config['csrf_protection']['enabled']) {
  287.             $config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class);
  288.         }
  289.         $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container$loader);
  290.         if ($this->isConfigEnabled($container$config['form'])) {
  291.             if (!class_exists(\Symfony\Component\Form\Form::class)) {
  292.                 throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
  293.             }
  294.             $this->formConfigEnabled true;
  295.             $this->registerFormConfiguration($config$container$loader);
  296.             if (class_exists(\Symfony\Component\Validator\Validation::class)) {
  297.                 $config['validation']['enabled'] = true;
  298.             } else {
  299.                 $container->setParameter('validator.translation_domain''validators');
  300.                 $container->removeDefinition('form.type_extension.form.validator');
  301.                 $container->removeDefinition('form.type_guesser.validator');
  302.             }
  303.         } else {
  304.             $container->removeDefinition('console.command.form_debug');
  305.         }
  306.         if ($this->isConfigEnabled($container$config['assets'])) {
  307.             if (!class_exists(\Symfony\Component\Asset\Package::class)) {
  308.                 throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
  309.             }
  310.             $this->registerAssetsConfiguration($config['assets'], $container$loader);
  311.         }
  312.         if ($this->messengerConfigEnabled $this->isConfigEnabled($container$config['messenger'])) {
  313.             $this->registerMessengerConfiguration($config['messenger'], $container$loader$config['validation']);
  314.         } else {
  315.             $container->removeDefinition('console.command.messenger_consume_messages');
  316.             $container->removeDefinition('console.command.messenger_debug');
  317.             $container->removeDefinition('console.command.messenger_stop_workers');
  318.             $container->removeDefinition('console.command.messenger_setup_transports');
  319.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  320.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  321.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  322.             $container->removeDefinition('cache.messenger.restart_workers_signal');
  323.             if ($container->hasDefinition('messenger.transport.amqp.factory') && !class_exists(AmqpTransportFactory::class)) {
  324.                 if (class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory::class)) {
  325.                     $container->getDefinition('messenger.transport.amqp.factory')
  326.                         ->setClass(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory::class)
  327.                         ->addTag('messenger.transport_factory');
  328.                 } else {
  329.                     $container->removeDefinition('messenger.transport.amqp.factory');
  330.                 }
  331.             }
  332.             if ($container->hasDefinition('messenger.transport.redis.factory') && !class_exists(RedisTransportFactory::class)) {
  333.                 if (class_exists(\Symfony\Component\Messenger\Transport\RedisExt\RedisTransportFactory::class)) {
  334.                     $container->getDefinition('messenger.transport.redis.factory')
  335.                         ->setClass(\Symfony\Component\Messenger\Transport\RedisExt\RedisTransportFactory::class)
  336.                         ->addTag('messenger.transport_factory');
  337.                 } else {
  338.                     $container->removeDefinition('messenger.transport.redis.factory');
  339.                 }
  340.             }
  341.         }
  342.         if ($this->httpClientConfigEnabled $this->isConfigEnabled($container$config['http_client'])) {
  343.             $this->registerHttpClientConfiguration($config['http_client'], $container$loader$config['profiler']);
  344.         }
  345.         if ($this->mailerConfigEnabled $this->isConfigEnabled($container$config['mailer'])) {
  346.             $this->registerMailerConfiguration($config['mailer'], $container$loader);
  347.         }
  348.         if ($this->notifierConfigEnabled $this->isConfigEnabled($container$config['notifier'])) {
  349.             $this->registerNotifierConfiguration($config['notifier'], $container$loader);
  350.         }
  351.         $propertyInfoEnabled $this->isConfigEnabled($container$config['property_info']);
  352.         $this->registerValidationConfiguration($config['validation'], $container$loader$propertyInfoEnabled);
  353.         $this->registerHttpCacheConfiguration($config['http_cache'], $container);
  354.         $this->registerEsiConfiguration($config['esi'], $container$loader);
  355.         $this->registerSsiConfiguration($config['ssi'], $container$loader);
  356.         $this->registerFragmentsConfiguration($config['fragments'], $container$loader);
  357.         $this->registerTranslatorConfiguration($config['translator'], $container$loader$config['default_locale']);
  358.         $this->registerProfilerConfiguration($config['profiler'], $container$loader);
  359.         $this->registerWorkflowConfiguration($config['workflows'], $container$loader);
  360.         $this->registerDebugConfiguration($config['php_errors'], $container$loader);
  361.         $this->registerRouterConfiguration($config['router'], $container$loader$config['translator']['enabled_locales'] ?? []);
  362.         $this->registerAnnotationsConfiguration($config['annotations'], $container$loader);
  363.         $this->registerPropertyAccessConfiguration($config['property_access'], $container$loader);
  364.         $this->registerSecretsConfiguration($config['secrets'], $container$loader);
  365.         if ($this->isConfigEnabled($container$config['serializer'])) {
  366.             if (!class_exists(\Symfony\Component\Serializer\Serializer::class)) {
  367.                 throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
  368.             }
  369.             $this->registerSerializerConfiguration($config['serializer'], $container$loader);
  370.         }
  371.         if ($propertyInfoEnabled) {
  372.             $this->registerPropertyInfoConfiguration($container$loader);
  373.         }
  374.         if ($this->lockConfigEnabled $this->isConfigEnabled($container$config['lock'])) {
  375.             $this->registerLockConfiguration($config['lock'], $container$loader);
  376.         }
  377.         if ($this->isConfigEnabled($container$config['rate_limiter'])) {
  378.             if (!interface_exists(LimiterInterface::class)) {
  379.                 throw new LogicException('Rate limiter support cannot be enabled as the RateLimiter component is not installed. Try running "composer require symfony/rate-limiter".');
  380.             }
  381.             $this->registerRateLimiterConfiguration($config['rate_limiter'], $container$loader);
  382.         }
  383.         if ($this->isConfigEnabled($container$config['web_link'])) {
  384.             if (!class_exists(HttpHeaderSerializer::class)) {
  385.                 throw new LogicException('WebLink support cannot be enabled as the WebLink component is not installed. Try running "composer require symfony/weblink".');
  386.             }
  387.             $loader->load('web_link.php');
  388.         }
  389.         $this->addAnnotatedClassesToCompile([
  390.             '**\\Controller\\',
  391.             '**\\Entity\\',
  392.             // Added explicitly so that we don't rely on the class map being dumped to make it work
  393.             'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController',
  394.         ]);
  395.         if (class_exists(MimeTypes::class)) {
  396.             $loader->load('mime_type.php');
  397.         }
  398.         $container->registerForAutoconfiguration(Command::class)
  399.             ->addTag('console.command');
  400.         $container->registerForAutoconfiguration(ResourceCheckerInterface::class)
  401.             ->addTag('config_cache.resource_checker');
  402.         $container->registerForAutoconfiguration(EnvVarLoaderInterface::class)
  403.             ->addTag('container.env_var_loader');
  404.         $container->registerForAutoconfiguration(EnvVarProcessorInterface::class)
  405.             ->addTag('container.env_var_processor');
  406.         $container->registerForAutoconfiguration(CallbackInterface::class)
  407.             ->addTag('container.reversible');
  408.         $container->registerForAutoconfiguration(ServiceLocator::class)
  409.             ->addTag('container.service_locator');
  410.         $container->registerForAutoconfiguration(ServiceSubscriberInterface::class)
  411.             ->addTag('container.service_subscriber');
  412.         $container->registerForAutoconfiguration(ArgumentValueResolverInterface::class)
  413.             ->addTag('controller.argument_value_resolver');
  414.         $container->registerForAutoconfiguration(AbstractController::class)
  415.             ->addTag('controller.service_arguments');
  416.         $container->registerForAutoconfiguration(DataCollectorInterface::class)
  417.             ->addTag('data_collector');
  418.         $container->registerForAutoconfiguration(FormTypeInterface::class)
  419.             ->addTag('form.type');
  420.         $container->registerForAutoconfiguration(FormTypeGuesserInterface::class)
  421.             ->addTag('form.type_guesser');
  422.         $container->registerForAutoconfiguration(FormTypeExtensionInterface::class)
  423.             ->addTag('form.type_extension');
  424.         $container->registerForAutoconfiguration(CacheClearerInterface::class)
  425.             ->addTag('kernel.cache_clearer');
  426.         $container->registerForAutoconfiguration(CacheWarmerInterface::class)
  427.             ->addTag('kernel.cache_warmer');
  428.         $container->registerForAutoconfiguration(EventSubscriberInterface::class)
  429.             ->addTag('kernel.event_subscriber');
  430.         $container->registerForAutoconfiguration(LocaleAwareInterface::class)
  431.             ->addTag('kernel.locale_aware');
  432.         $container->registerForAutoconfiguration(ResetInterface::class)
  433.             ->addTag('kernel.reset', ['method' => 'reset']);
  434.         if (!interface_exists(MarshallerInterface::class)) {
  435.             $container->registerForAutoconfiguration(ResettableInterface::class)
  436.                 ->addTag('kernel.reset', ['method' => 'reset']);
  437.         }
  438.         $container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
  439.             ->addTag('property_info.list_extractor');
  440.         $container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
  441.             ->addTag('property_info.type_extractor');
  442.         $container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class)
  443.             ->addTag('property_info.description_extractor');
  444.         $container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class)
  445.             ->addTag('property_info.access_extractor');
  446.         $container->registerForAutoconfiguration(PropertyInitializableExtractorInterface::class)
  447.             ->addTag('property_info.initializable_extractor');
  448.         $container->registerForAutoconfiguration(EncoderInterface::class)
  449.             ->addTag('serializer.encoder');
  450.         $container->registerForAutoconfiguration(DecoderInterface::class)
  451.             ->addTag('serializer.encoder');
  452.         $container->registerForAutoconfiguration(NormalizerInterface::class)
  453.             ->addTag('serializer.normalizer');
  454.         $container->registerForAutoconfiguration(DenormalizerInterface::class)
  455.             ->addTag('serializer.normalizer');
  456.         $container->registerForAutoconfiguration(ConstraintValidatorInterface::class)
  457.             ->addTag('validator.constraint_validator');
  458.         $container->registerForAutoconfiguration(ObjectInitializerInterface::class)
  459.             ->addTag('validator.initializer');
  460.         $container->registerForAutoconfiguration(MessageHandlerInterface::class)
  461.             ->addTag('messenger.message_handler');
  462.         $container->registerForAutoconfiguration(TransportFactoryInterface::class)
  463.             ->addTag('messenger.transport_factory');
  464.         $container->registerForAutoconfiguration(MimeTypeGuesserInterface::class)
  465.             ->addTag('mime.mime_type_guesser');
  466.         $container->registerForAutoconfiguration(LoggerAwareInterface::class)
  467.             ->addMethodCall('setLogger', [new Reference('logger')]);
  468.         if (!$container->getParameter('kernel.debug')) {
  469.             // remove tagged iterator argument for resource checkers
  470.             $container->getDefinition('config_cache_factory')->setArguments([]);
  471.         }
  472.         if (!$config['disallow_search_engine_index'] ?? false) {
  473.             $container->removeDefinition('disallow_search_engine_index_response_listener');
  474.         }
  475.         $container->registerForAutoconfiguration(RouteLoaderInterface::class)
  476.             ->addTag('routing.route_loader');
  477.         $container->setParameter('container.behavior_describing_tags', [
  478.             'container.service_locator',
  479.             'container.service_subscriber',
  480.             'kernel.event_subscriber',
  481.             'kernel.locale_aware',
  482.             'kernel.reset',
  483.         ]);
  484.     }
  485.     /**
  486.      * {@inheritdoc}
  487.      */
  488.     public function getConfiguration(array $configContainerBuilder $container)
  489.     {
  490.         return new Configuration($container->getParameter('kernel.debug'));
  491.     }
  492.     private function registerFormConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  493.     {
  494.         $loader->load('form.php');
  495.         $container->getDefinition('form.type_extension.form.validator')->setArgument(1$config['form']['legacy_error_messages']);
  496.         if (null === $config['form']['csrf_protection']['enabled']) {
  497.             $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
  498.         }
  499.         if ($this->isConfigEnabled($container$config['form']['csrf_protection'])) {
  500.             $loader->load('form_csrf.php');
  501.             $container->setParameter('form.type_extension.csrf.enabled'true);
  502.             $container->setParameter('form.type_extension.csrf.field_name'$config['form']['csrf_protection']['field_name']);
  503.         } else {
  504.             $container->setParameter('form.type_extension.csrf.enabled'false);
  505.         }
  506.         if (!class_exists(Translator::class)) {
  507.             $container->removeDefinition('form.type_extension.upload.validator');
  508.         }
  509.         if (!method_exists(CachingFactoryDecorator::class, 'reset')) {
  510.             $container->getDefinition('form.choice_list_factory.cached')
  511.                 ->clearTag('kernel.reset')
  512.             ;
  513.         }
  514.     }
  515.     private function registerHttpCacheConfiguration(array $configContainerBuilder $container)
  516.     {
  517.         $options $config;
  518.         unset($options['enabled']);
  519.         if (!$options['private_headers']) {
  520.             unset($options['private_headers']);
  521.         }
  522.         $container->getDefinition('http_cache')
  523.             ->setPublic($config['enabled'])
  524.             ->replaceArgument(3$options);
  525.     }
  526.     private function registerEsiConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  527.     {
  528.         if (!$this->isConfigEnabled($container$config)) {
  529.             $container->removeDefinition('fragment.renderer.esi');
  530.             return;
  531.         }
  532.         $loader->load('esi.php');
  533.     }
  534.     private function registerSsiConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  535.     {
  536.         if (!$this->isConfigEnabled($container$config)) {
  537.             $container->removeDefinition('fragment.renderer.ssi');
  538.             return;
  539.         }
  540.         $loader->load('ssi.php');
  541.     }
  542.     private function registerFragmentsConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  543.     {
  544.         if (!$this->isConfigEnabled($container$config)) {
  545.             $container->removeDefinition('fragment.renderer.hinclude');
  546.             return;
  547.         }
  548.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  549.         $loader->load('fragment_listener.php');
  550.         $container->setParameter('fragment.path'$config['path']);
  551.     }
  552.     private function registerProfilerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  553.     {
  554.         if (!$this->isConfigEnabled($container$config)) {
  555.             // this is needed for the WebProfiler to work even if the profiler is disabled
  556.             $container->setParameter('data_collector.templates', []);
  557.             return;
  558.         }
  559.         $loader->load('profiling.php');
  560.         $loader->load('collectors.php');
  561.         $loader->load('cache_debug.php');
  562.         if ($this->formConfigEnabled) {
  563.             $loader->load('form_debug.php');
  564.         }
  565.         if ($this->validatorConfigEnabled) {
  566.             $loader->load('validator_debug.php');
  567.         }
  568.         if ($this->translationConfigEnabled) {
  569.             $loader->load('translation_debug.php');
  570.             $container->getDefinition('translator.data_collector')->setDecoratedService('translator');
  571.         }
  572.         if ($this->messengerConfigEnabled) {
  573.             $loader->load('messenger_debug.php');
  574.         }
  575.         if ($this->mailerConfigEnabled) {
  576.             $loader->load('mailer_debug.php');
  577.         }
  578.         if ($this->httpClientConfigEnabled) {
  579.             $loader->load('http_client_debug.php');
  580.         }
  581.         if ($this->notifierConfigEnabled) {
  582.             $loader->load('notifier_debug.php');
  583.         }
  584.         $container->setParameter('profiler_listener.only_exceptions'$config['only_exceptions']);
  585.         $container->setParameter('profiler_listener.only_master_requests'$config['only_master_requests']);
  586.         // Choose storage class based on the DSN
  587.         [$class] = explode(':'$config['dsn'], 2);
  588.         if ('file' !== $class) {
  589.             throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.'$class));
  590.         }
  591.         $container->setParameter('profiler.storage.dsn'$config['dsn']);
  592.         $container->getDefinition('profiler')
  593.             ->addArgument($config['collect'])
  594.             ->addTag('kernel.reset', ['method' => 'reset']);
  595.     }
  596.     private function registerWorkflowConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  597.     {
  598.         if (!$config['enabled']) {
  599.             $container->removeDefinition('console.command.workflow_dump');
  600.             return;
  601.         }
  602.         if (!class_exists(Workflow\Workflow::class)) {
  603.             throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed. Try running "composer require symfony/workflow".');
  604.         }
  605.         $loader->load('workflow.php');
  606.         $registryDefinition $container->getDefinition('workflow.registry');
  607.         foreach ($config['workflows'] as $name => $workflow) {
  608.             $type $workflow['type'];
  609.             $workflowId sprintf('%s.%s'$type$name);
  610.             // Process Metadata (workflow + places (transition is done in the "create transition" block))
  611.             $metadataStoreDefinition = new Definition(Workflow\Metadata\InMemoryMetadataStore::class, [[], [], null]);
  612.             if ($workflow['metadata']) {
  613.                 $metadataStoreDefinition->replaceArgument(0$workflow['metadata']);
  614.             }
  615.             $placesMetadata = [];
  616.             foreach ($workflow['places'] as $place) {
  617.                 if ($place['metadata']) {
  618.                     $placesMetadata[$place['name']] = $place['metadata'];
  619.                 }
  620.             }
  621.             if ($placesMetadata) {
  622.                 $metadataStoreDefinition->replaceArgument(1$placesMetadata);
  623.             }
  624.             // Create transitions
  625.             $transitions = [];
  626.             $guardsConfiguration = [];
  627.             $transitionsMetadataDefinition = new Definition(\SplObjectStorage::class);
  628.             // Global transition counter per workflow
  629.             $transitionCounter 0;
  630.             foreach ($workflow['transitions'] as $transition) {
  631.                 if ('workflow' === $type) {
  632.                     $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]);
  633.                     $transitionDefinition->setPublic(false);
  634.                     $transitionId sprintf('.%s.transition.%s'$workflowId$transitionCounter++);
  635.                     $container->setDefinition($transitionId$transitionDefinition);
  636.                     $transitions[] = new Reference($transitionId);
  637.                     if (isset($transition['guard'])) {
  638.                         $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  639.                         $configuration->addArgument(new Reference($transitionId));
  640.                         $configuration->addArgument($transition['guard']);
  641.                         $configuration->setPublic(false);
  642.                         $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  643.                         $guardsConfiguration[$eventName][] = $configuration;
  644.                     }
  645.                     if ($transition['metadata']) {
  646.                         $transitionsMetadataDefinition->addMethodCall('attach', [
  647.                             new Reference($transitionId),
  648.                             $transition['metadata'],
  649.                         ]);
  650.                     }
  651.                 } elseif ('state_machine' === $type) {
  652.                     foreach ($transition['from'] as $from) {
  653.                         foreach ($transition['to'] as $to) {
  654.                             $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from$to]);
  655.                             $transitionDefinition->setPublic(false);
  656.                             $transitionId sprintf('.%s.transition.%s'$workflowId$transitionCounter++);
  657.                             $container->setDefinition($transitionId$transitionDefinition);
  658.                             $transitions[] = new Reference($transitionId);
  659.                             if (isset($transition['guard'])) {
  660.                                 $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  661.                                 $configuration->addArgument(new Reference($transitionId));
  662.                                 $configuration->addArgument($transition['guard']);
  663.                                 $configuration->setPublic(false);
  664.                                 $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  665.                                 $guardsConfiguration[$eventName][] = $configuration;
  666.                             }
  667.                             if ($transition['metadata']) {
  668.                                 $transitionsMetadataDefinition->addMethodCall('attach', [
  669.                                     new Reference($transitionId),
  670.                                     $transition['metadata'],
  671.                                 ]);
  672.                             }
  673.                         }
  674.                     }
  675.                 }
  676.             }
  677.             $metadataStoreDefinition->replaceArgument(2$transitionsMetadataDefinition);
  678.             $container->setDefinition(sprintf('%s.metadata_store'$workflowId), $metadataStoreDefinition);
  679.             // Create places
  680.             $places array_column($workflow['places'], 'name');
  681.             $initialMarking $workflow['initial_marking'] ?? [];
  682.             // Create a Definition
  683.             $definitionDefinition = new Definition(Workflow\Definition::class);
  684.             $definitionDefinition->setPublic(false);
  685.             $definitionDefinition->addArgument($places);
  686.             $definitionDefinition->addArgument($transitions);
  687.             $definitionDefinition->addArgument($initialMarking);
  688.             $definitionDefinition->addArgument(new Reference(sprintf('%s.metadata_store'$workflowId)));
  689.             $definitionDefinition->addTag('workflow.definition', [
  690.                 'name' => $name,
  691.                 'type' => $type,
  692.             ]);
  693.             // Create MarkingStore
  694.             if (isset($workflow['marking_store']['type'])) {
  695.                 $markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
  696.                 $markingStoreDefinition->setArguments([
  697.                     'state_machine' === $type//single state
  698.                     $workflow['marking_store']['property'],
  699.                 ]);
  700.             } elseif (isset($workflow['marking_store']['service'])) {
  701.                 $markingStoreDefinition = new Reference($workflow['marking_store']['service']);
  702.             }
  703.             // Create Workflow
  704.             $workflowDefinition = new ChildDefinition(sprintf('%s.abstract'$type));
  705.             $workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition'$workflowId)));
  706.             $workflowDefinition->replaceArgument(1$markingStoreDefinition ?? null);
  707.             $workflowDefinition->replaceArgument(3$name);
  708.             $workflowDefinition->replaceArgument(4$workflow['events_to_dispatch']);
  709.             // Store to container
  710.             $container->setDefinition($workflowId$workflowDefinition);
  711.             $container->setDefinition(sprintf('%s.definition'$workflowId), $definitionDefinition);
  712.             $container->registerAliasForArgument($workflowIdWorkflowInterface::class, $name.'.'.$type);
  713.             // Validate Workflow
  714.             if ('state_machine' === $workflow['type']) {
  715.                 $validator = new Workflow\Validator\StateMachineValidator();
  716.             } else {
  717.                 $validator = new Workflow\Validator\WorkflowValidator();
  718.             }
  719.             $trs array_map(function (Reference $ref) use ($container): Workflow\Transition {
  720.                 return $container->get((string) $ref);
  721.             }, $transitions);
  722.             $realDefinition = new Workflow\Definition($places$trs$initialMarking);
  723.             $validator->validate($realDefinition$name);
  724.             // Add workflow to Registry
  725.             if ($workflow['supports']) {
  726.                 foreach ($workflow['supports'] as $supportedClassName) {
  727.                     $strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, [$supportedClassName]);
  728.                     $strategyDefinition->setPublic(false);
  729.                     $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
  730.                 }
  731.             } elseif (isset($workflow['support_strategy'])) {
  732.                 $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), new Reference($workflow['support_strategy'])]);
  733.             }
  734.             // Enable the AuditTrail
  735.             if ($workflow['audit_trail']['enabled']) {
  736.                 $listener = new Definition(Workflow\EventListener\AuditTrailListener::class);
  737.                 $listener->addTag('monolog.logger', ['channel' => 'workflow']);
  738.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave'$name), 'method' => 'onLeave']);
  739.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition'$name), 'method' => 'onTransition']);
  740.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter'$name), 'method' => 'onEnter']);
  741.                 $listener->addArgument(new Reference('logger'));
  742.                 $container->setDefinition(sprintf('.%s.listener.audit_trail'$workflowId), $listener);
  743.             }
  744.             // Add Guard Listener
  745.             if ($guardsConfiguration) {
  746.                 if (!class_exists(ExpressionLanguage::class)) {
  747.                     throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
  748.                 }
  749.                 if (!class_exists(Security::class)) {
  750.                     throw new LogicException('Cannot guard workflows as the Security component is not installed. Try running "composer require symfony/security-core".');
  751.                 }
  752.                 $guard = new Definition(Workflow\EventListener\GuardListener::class);
  753.                 $guard->setArguments([
  754.                     $guardsConfiguration,
  755.                     new Reference('workflow.security.expression_language'),
  756.                     new Reference('security.token_storage'),
  757.                     new Reference('security.authorization_checker'),
  758.                     new Reference('security.authentication.trust_resolver'),
  759.                     new Reference('security.role_hierarchy'),
  760.                     new Reference('validator'ContainerInterface::NULL_ON_INVALID_REFERENCE),
  761.                 ]);
  762.                 foreach ($guardsConfiguration as $eventName => $config) {
  763.                     $guard->addTag('kernel.event_listener', ['event' => $eventName'method' => 'onTransition']);
  764.                 }
  765.                 $container->setDefinition(sprintf('.%s.listener.guard'$workflowId), $guard);
  766.                 $container->setParameter('workflow.has_guard_listeners'true);
  767.             }
  768.         }
  769.     }
  770.     private function registerDebugConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  771.     {
  772.         $loader->load('debug_prod.php');
  773.         if (class_exists(Stopwatch::class)) {
  774.             $container->register('debug.stopwatch'Stopwatch::class)
  775.                 ->addArgument(true)
  776.                 ->addTag('kernel.reset', ['method' => 'reset']);
  777.             $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch'false));
  778.         }
  779.         $debug $container->getParameter('kernel.debug');
  780.         if ($debug) {
  781.             $container->setParameter('debug.container.dump''%kernel.build_dir%/%kernel.container_class%.xml');
  782.         }
  783.         if ($debug && class_exists(Stopwatch::class)) {
  784.             $loader->load('debug.php');
  785.         }
  786.         $definition $container->findDefinition('debug.debug_handlers_listener');
  787.         if (false === $config['log']) {
  788.             $definition->replaceArgument(1null);
  789.         } elseif (true !== $config['log']) {
  790.             $definition->replaceArgument(2$config['log']);
  791.         }
  792.         if (!$config['throw']) {
  793.             $container->setParameter('debug.error_handler.throw_at'0);
  794.         }
  795.         if ($debug && class_exists(DebugProcessor::class)) {
  796.             $definition = new Definition(DebugProcessor::class);
  797.             $definition->setPublic(false);
  798.             $definition->addArgument(new Reference('request_stack'));
  799.             $container->setDefinition('debug.log_processor'$definition);
  800.         }
  801.     }
  802.     private function registerRouterConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader, array $enabledLocales = [])
  803.     {
  804.         if (!$this->isConfigEnabled($container$config)) {
  805.             $container->removeDefinition('console.command.router_debug');
  806.             $container->removeDefinition('console.command.router_match');
  807.             return;
  808.         }
  809.         $loader->load('routing.php');
  810.         if (null === $config['utf8']) {
  811.             trigger_deprecation('symfony/framework-bundle''5.1''Not setting the "framework.router.utf8" configuration option is deprecated, it will default to "true" in version 6.0.');
  812.         }
  813.         if ($config['utf8']) {
  814.             $container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
  815.         }
  816.         if ($enabledLocales) {
  817.             $enabledLocales implode('|'array_map('preg_quote'$enabledLocales));
  818.             $container->getDefinition('routing.loader')->replaceArgument(2, ['_locale' => $enabledLocales]);
  819.         }
  820.         if (!class_exists(ExpressionLanguage::class)) {
  821.             $container->removeDefinition('router.expression_language_provider');
  822.         }
  823.         $container->setParameter('router.resource'$config['resource']);
  824.         $router $container->findDefinition('router.default');
  825.         $argument $router->getArgument(2);
  826.         $argument['strict_requirements'] = $config['strict_requirements'];
  827.         if (isset($config['type'])) {
  828.             $argument['resource_type'] = $config['type'];
  829.         }
  830.         $router->replaceArgument(2$argument);
  831.         $container->setParameter('request_listener.http_port'$config['http_port']);
  832.         $container->setParameter('request_listener.https_port'$config['https_port']);
  833.         if (null !== $config['default_uri']) {
  834.             $container->getDefinition('router.request_context')
  835.                 ->replaceArgument(0$config['default_uri']);
  836.         }
  837.         if (\PHP_VERSION_ID >= 80000 || $this->annotationsConfigEnabled) {
  838.             $container->register('routing.loader.annotation'AnnotatedRouteControllerLoader::class)
  839.                 ->setPublic(false)
  840.                 ->addTag('routing.loader', ['priority' => -10])
  841.                 ->addArgument(new Reference('annotation_reader'ContainerInterface::NULL_ON_INVALID_REFERENCE));
  842.             $container->register('routing.loader.annotation.directory'AnnotationDirectoryLoader::class)
  843.                 ->setPublic(false)
  844.                 ->addTag('routing.loader', ['priority' => -10])
  845.                 ->setArguments([
  846.                     new Reference('file_locator'),
  847.                     new Reference('routing.loader.annotation'),
  848.                 ]);
  849.             $container->register('routing.loader.annotation.file'AnnotationFileLoader::class)
  850.                 ->setPublic(false)
  851.                 ->addTag('routing.loader', ['priority' => -10])
  852.                 ->setArguments([
  853.                     new Reference('file_locator'),
  854.                     new Reference('routing.loader.annotation'),
  855.                 ]);
  856.         }
  857.     }
  858.     private function registerSessionConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  859.     {
  860.         $loader->load('session.php');
  861.         // session storage
  862.         $container->setAlias('session.storage'$config['storage_id']);
  863.         $options = ['cache_limiter' => '0'];
  864.         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) {
  865.             if (isset($config[$key])) {
  866.                 $options[$key] = $config[$key];
  867.             }
  868.         }
  869.         if ('auto' === ($options['cookie_secure'] ?? null)) {
  870.             $locator $container->getDefinition('session_listener')->getArgument(0);
  871.             $locator->setValues($locator->getValues() + [
  872.                 'session_storage' => new Reference('session.storage'ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
  873.                 'request_stack' => new Reference('request_stack'),
  874.             ]);
  875.         }
  876.         $container->setParameter('session.storage.options'$options);
  877.         // session handler (the internal callback registered with PHP session management)
  878.         if (null === $config['handler_id']) {
  879.             // Set the handler class to be null
  880.             $container->getDefinition('session.storage.native')->replaceArgument(1null);
  881.             $container->getDefinition('session.storage.php_bridge')->replaceArgument(0null);
  882.             $container->setAlias('session.handler''session.handler.native_file');
  883.         } else {
  884.             $container->resolveEnvPlaceholders($config['handler_id'], null$usedEnvs);
  885.             if ($usedEnvs || preg_match('#^[a-z]++://#'$config['handler_id'])) {
  886.                 $id '.cache_connection.'.ContainerBuilder::hash($config['handler_id']);
  887.                 $container->getDefinition('session.abstract_handler')
  888.                     ->replaceArgument(0$container->hasDefinition($id) ? new Reference($id) : $config['handler_id']);
  889.                 $container->setAlias('session.handler''session.abstract_handler');
  890.             } else {
  891.                 $container->setAlias('session.handler'$config['handler_id']);
  892.             }
  893.         }
  894.         $container->setParameter('session.save_path'$config['save_path']);
  895.         $container->setParameter('session.metadata.update_threshold'$config['metadata_update_threshold']);
  896.     }
  897.     private function registerRequestConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  898.     {
  899.         if ($config['formats']) {
  900.             $loader->load('request.php');
  901.             $listener $container->getDefinition('request.add_request_formats_listener');
  902.             $listener->replaceArgument(0$config['formats']);
  903.         }
  904.     }
  905.     private function registerAssetsConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  906.     {
  907.         $loader->load('assets.php');
  908.         if ($config['version_strategy']) {
  909.             $defaultVersion = new Reference($config['version_strategy']);
  910.         } else {
  911.             $defaultVersion $this->createVersion($container$config['version'], $config['version_format'], $config['json_manifest_path'], '_default');
  912.         }
  913.         $defaultPackage $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
  914.         $container->setDefinition('assets._default_package'$defaultPackage);
  915.         $namedPackages = [];
  916.         foreach ($config['packages'] as $name => $package) {
  917.             if (null !== $package['version_strategy']) {
  918.                 $version = new Reference($package['version_strategy']);
  919.             } elseif (!\array_key_exists('version'$package) && null === $package['json_manifest_path']) {
  920.                 // if neither version nor json_manifest_path are specified, use the default
  921.                 $version $defaultVersion;
  922.             } else {
  923.                 // let format fallback to main version_format
  924.                 $format $package['version_format'] ?: $config['version_format'];
  925.                 $version $package['version'] ?? null;
  926.                 $version $this->createVersion($container$version$format$package['json_manifest_path'], $name);
  927.             }
  928.             $container->setDefinition('assets._package_'.$name$this->createPackageDefinition($package['base_path'], $package['base_urls'], $version));
  929.             $container->registerAliasForArgument('assets._package_'.$namePackageInterface::class, $name.'.package');
  930.             $namedPackages[$name] = new Reference('assets._package_'.$name);
  931.         }
  932.         $container->getDefinition('assets.packages')
  933.             ->replaceArgument(0, new Reference('assets._default_package'))
  934.             ->replaceArgument(1$namedPackages)
  935.         ;
  936.     }
  937.     /**
  938.      * Returns a definition for an asset package.
  939.      */
  940.     private function createPackageDefinition(?string $basePath, array $baseUrlsReference $version): Definition
  941.     {
  942.         if ($basePath && $baseUrls) {
  943.             throw new \LogicException('An asset package cannot have base URLs and base paths.');
  944.         }
  945.         $package = new ChildDefinition($baseUrls 'assets.url_package' 'assets.path_package');
  946.         $package
  947.             ->setPublic(false)
  948.             ->replaceArgument(0$baseUrls ?: $basePath)
  949.             ->replaceArgument(1$version)
  950.         ;
  951.         return $package;
  952.     }
  953.     private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPathstring $name): Reference
  954.     {
  955.         // Configuration prevents $version and $jsonManifestPath from being set
  956.         if (null !== $version) {
  957.             $def = new ChildDefinition('assets.static_version_strategy');
  958.             $def
  959.                 ->replaceArgument(0$version)
  960.                 ->replaceArgument(1$format)
  961.             ;
  962.             $container->setDefinition('assets._version_'.$name$def);
  963.             return new Reference('assets._version_'.$name);
  964.         }
  965.         if (null !== $jsonManifestPath) {
  966.             $definitionName 'assets.json_manifest_version_strategy';
  967.             if (=== strpos(parse_url($jsonManifestPath, \PHP_URL_SCHEME), 'http')) {
  968.                 $definitionName 'assets.remote_json_manifest_version_strategy';
  969.             }
  970.             $def = new ChildDefinition($definitionName);
  971.             $def->replaceArgument(0$jsonManifestPath);
  972.             $container->setDefinition('assets._version_'.$name$def);
  973.             return new Reference('assets._version_'.$name);
  974.         }
  975.         return new Reference('assets.empty_version_strategy');
  976.     }
  977.     private function registerTranslatorConfiguration(array $configContainerBuilder $containerLoaderInterface $loaderstring $defaultLocale)
  978.     {
  979.         if (!$this->isConfigEnabled($container$config)) {
  980.             $container->removeDefinition('console.command.translation_debug');
  981.             $container->removeDefinition('console.command.translation_update');
  982.             return;
  983.         }
  984.         $loader->load('translation.php');
  985.         // Use the "real" translator instead of the identity default
  986.         $container->setAlias('translator''translator.default')->setPublic(true);
  987.         $container->setAlias('translator.formatter', new Alias($config['formatter'], false));
  988.         $translator $container->findDefinition('translator.default');
  989.         $translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
  990.         $defaultOptions $translator->getArgument(4);
  991.         $defaultOptions['cache_dir'] = $config['cache_dir'];
  992.         $translator->setArgument(4$defaultOptions);
  993.         $translator->setArgument(5$config['enabled_locales']);
  994.         $container->setParameter('translator.logging'$config['logging']);
  995.         $container->setParameter('translator.default_path'$config['default_path']);
  996.         // Discover translation directories
  997.         $dirs = [];
  998.         $transPaths = [];
  999.         $nonExistingDirs = [];
  1000.         if (class_exists(\Symfony\Component\Validator\Validation::class)) {
  1001.             $r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
  1002.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  1003.         }
  1004.         if (class_exists(\Symfony\Component\Form\Form::class)) {
  1005.             $r = new \ReflectionClass(\Symfony\Component\Form\Form::class);
  1006.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  1007.         }
  1008.         if (class_exists(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) {
  1009.             $r = new \ReflectionClass(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
  1010.             $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
  1011.         }
  1012.         $defaultDir $container->getParameterBag()->resolveValue($config['default_path']);
  1013.         foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
  1014.             if ($container->fileExists($dir $bundle['path'].'/Resources/translations') || $container->fileExists($dir $bundle['path'].'/translations')) {
  1015.                 $dirs[] = $dir;
  1016.             } else {
  1017.                 $nonExistingDirs[] = $dir;
  1018.             }
  1019.         }
  1020.         foreach ($config['paths'] as $dir) {
  1021.             if ($container->fileExists($dir)) {
  1022.                 $dirs[] = $transPaths[] = $dir;
  1023.             } else {
  1024.                 throw new \UnexpectedValueException(sprintf('"%s" defined in translator.paths does not exist or is not a directory.'$dir));
  1025.             }
  1026.         }
  1027.         if ($container->hasDefinition('console.command.translation_debug')) {
  1028.             $container->getDefinition('console.command.translation_debug')->replaceArgument(5$transPaths);
  1029.         }
  1030.         if ($container->hasDefinition('console.command.translation_update')) {
  1031.             $container->getDefinition('console.command.translation_update')->replaceArgument(6$transPaths);
  1032.         }
  1033.         if ($container->fileExists($defaultDir)) {
  1034.             $dirs[] = $defaultDir;
  1035.         } else {
  1036.             $nonExistingDirs[] = $defaultDir;
  1037.         }
  1038.         // Register translation resources
  1039.         if ($dirs) {
  1040.             $files = [];
  1041.             foreach ($dirs as $dir) {
  1042.                 $finder Finder::create()
  1043.                     ->followLinks()
  1044.                     ->files()
  1045.                     ->filter(function (\SplFileInfo $file) {
  1046.                         return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  1047.                     })
  1048.                     ->in($dir)
  1049.                     ->sortByName()
  1050.                 ;
  1051.                 foreach ($finder as $file) {
  1052.                     $fileNameParts explode('.'basename($file));
  1053.                     $locale $fileNameParts[\count($fileNameParts) - 2];
  1054.                     if (!isset($files[$locale])) {
  1055.                         $files[$locale] = [];
  1056.                     }
  1057.                     $files[$locale][] = (string) $file;
  1058.                 }
  1059.             }
  1060.             $projectDir $container->getParameter('kernel.project_dir');
  1061.             $options array_merge(
  1062.                 $translator->getArgument(4),
  1063.                 [
  1064.                     'resource_files' => $files,
  1065.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1066.                     'cache_vary' => [
  1067.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1068.                             return === strpos($dir$projectDir.'/') ? substr($dir+ \strlen($projectDir)) : $dir;
  1069.                         }, $scannedDirectories),
  1070.                     ],
  1071.                 ]
  1072.             );
  1073.             $translator->replaceArgument(4$options);
  1074.         }
  1075.         if ($config['pseudo_localization']['enabled']) {
  1076.             $options $config['pseudo_localization'];
  1077.             unset($options['enabled']);
  1078.             $container
  1079.                 ->register('translator.pseudo'PseudoLocalizationTranslator::class)
  1080.                 ->setDecoratedService('translator'null, -1// Lower priority than "translator.data_collector"
  1081.                 ->setArguments([
  1082.                     new Reference('translator.pseudo.inner'),
  1083.                     $options,
  1084.                 ]);
  1085.         }
  1086.     }
  1087.     private function registerValidationConfiguration(array $configContainerBuilder $containerPhpFileLoader $loaderbool $propertyInfoEnabled)
  1088.     {
  1089.         if (!$this->validatorConfigEnabled $this->isConfigEnabled($container$config)) {
  1090.             $container->removeDefinition('console.command.validator_debug');
  1091.             return;
  1092.         }
  1093.         if (!class_exists(\Symfony\Component\Validator\Validation::class)) {
  1094.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1095.         }
  1096.         if (!isset($config['email_validation_mode'])) {
  1097.             $config['email_validation_mode'] = 'loose';
  1098.         }
  1099.         $loader->load('validator.php');
  1100.         $validatorBuilder $container->getDefinition('validator.builder');
  1101.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1102.         $files = ['xml' => [], 'yml' => []];
  1103.         $this->registerValidatorMapping($container$config$files);
  1104.         if (!empty($files['xml'])) {
  1105.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1106.         }
  1107.         if (!empty($files['yml'])) {
  1108.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1109.         }
  1110.         $definition $container->findDefinition('validator.email');
  1111.         $definition->replaceArgument(0$config['email_validation_mode']);
  1112.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1113.             if (!$this->annotationsConfigEnabled && \PHP_VERSION_ID 80000) {
  1114.                 throw new \LogicException('"enable_annotations" on the validator cannot be set as Doctrine Annotations support is disabled.');
  1115.             }
  1116.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [true]);
  1117.             if ($this->annotationsConfigEnabled) {
  1118.                 $validatorBuilder->addMethodCall('setDoctrineAnnotationReader', [new Reference('annotation_reader')]);
  1119.             }
  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.php');
  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_adapter')
  1221.                     ->replaceArgument(2$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');
  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 $containerPhpFileLoader $loader)
  1239.     {
  1240.         if (!class_exists(PropertyAccessor::class)) {
  1241.             return;
  1242.         }
  1243.         $loader->load('property_access.php');
  1244.         $magicMethods PropertyAccessor::DISALLOW_MAGIC_METHODS;
  1245.         $magicMethods |= $config['magic_call'] ? PropertyAccessor::MAGIC_CALL 0;
  1246.         $magicMethods |= $config['magic_get'] ? PropertyAccessor::MAGIC_GET 0;
  1247.         $magicMethods |= $config['magic_set'] ? PropertyAccessor::MAGIC_SET 0;
  1248.         $container
  1249.             ->getDefinition('property_accessor')
  1250.             ->replaceArgument(0$magicMethods)
  1251.             ->replaceArgument(1$config['throw_exception_on_invalid_index'])
  1252.             ->replaceArgument(3$config['throw_exception_on_invalid_property_path'])
  1253.             ->replaceArgument(4, new Reference(PropertyReadInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1254.             ->replaceArgument(5, new Reference(PropertyWriteInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1255.         ;
  1256.     }
  1257.     private function registerSecretsConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1258.     {
  1259.         if (!$this->isConfigEnabled($container$config)) {
  1260.             $container->removeDefinition('console.command.secrets_set');
  1261.             $container->removeDefinition('console.command.secrets_list');
  1262.             $container->removeDefinition('console.command.secrets_remove');
  1263.             $container->removeDefinition('console.command.secrets_generate_key');
  1264.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1265.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1266.             return;
  1267.         }
  1268.         $loader->load('secrets.php');
  1269.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1270.         if ($config['local_dotenv_file']) {
  1271.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1272.         } else {
  1273.             $container->removeDefinition('secrets.local_vault');
  1274.         }
  1275.         if ($config['decryption_env_var']) {
  1276.             if (!preg_match('/^(?:[-.\w]*+:)*+\w++$/'$config['decryption_env_var'])) {
  1277.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1278.             }
  1279.             if (class_exists(LazyString::class)) {
  1280.                 $container->getDefinition('secrets.decryption_key')->replaceArgument(1$config['decryption_env_var']);
  1281.             } else {
  1282.                 $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1283.                 $container->removeDefinition('secrets.decryption_key');
  1284.             }
  1285.         } else {
  1286.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1287.             $container->removeDefinition('secrets.decryption_key');
  1288.         }
  1289.     }
  1290.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1291.     {
  1292.         if (!$this->isConfigEnabled($container$config)) {
  1293.             return;
  1294.         }
  1295.         if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
  1296.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1297.         }
  1298.         if (!$this->sessionConfigEnabled) {
  1299.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1300.         }
  1301.         // Enable services for CSRF protection (even without forms)
  1302.         $loader->load('security_csrf.php');
  1303.         if (!class_exists(CsrfExtension::class)) {
  1304.             $container->removeDefinition('twig.extension.security_csrf');
  1305.         }
  1306.     }
  1307.     private function registerSerializerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1308.     {
  1309.         $loader->load('serializer.php');
  1310.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1311.         if (!class_exists(PropertyAccessor::class)) {
  1312.             $container->removeAlias('serializer.property_accessor');
  1313.             $container->removeDefinition('serializer.normalizer.object');
  1314.         }
  1315.         if (!class_exists(Yaml::class)) {
  1316.             $container->removeDefinition('serializer.encoder.yaml');
  1317.         }
  1318.         if (!class_exists(UnwrappingDenormalizer::class) || !class_exists(PropertyAccessor::class)) {
  1319.             $container->removeDefinition('serializer.denormalizer.unwrapping');
  1320.         }
  1321.         if (!class_exists(Headers::class)) {
  1322.             $container->removeDefinition('serializer.normalizer.mime_message');
  1323.         }
  1324.         $serializerLoaders = [];
  1325.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1326.             if (\PHP_VERSION_ID 80000 && !$this->annotationsConfigEnabled) {
  1327.                 throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
  1328.             }
  1329.             $annotationLoader = new Definition(
  1330.                 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
  1331.                 [new Reference('annotation_reader'ContainerInterface::NULL_ON_INVALID_REFERENCE)]
  1332.             );
  1333.             $annotationLoader->setPublic(false);
  1334.             $serializerLoaders[] = $annotationLoader;
  1335.         }
  1336.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1337.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
  1338.             $definition->setPublic(false);
  1339.             $serializerLoaders[] = $definition;
  1340.         };
  1341.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1342.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1343.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1344.                 $fileRecorder('xml'$file);
  1345.             }
  1346.             if (
  1347.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1348.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1349.             ) {
  1350.                 $fileRecorder('yml'$file);
  1351.             }
  1352.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1353.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1354.             }
  1355.         }
  1356.         $projectDir $container->getParameter('kernel.project_dir');
  1357.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1358.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1359.         }
  1360.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1361.         $chainLoader->replaceArgument(0$serializerLoaders);
  1362.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1363.         if (isset($config['name_converter']) && $config['name_converter']) {
  1364.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1365.         }
  1366.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1367.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1368.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1369.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1370.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1371.         }
  1372.         if ($config['max_depth_handler'] ?? false) {
  1373.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1374.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1375.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1376.         }
  1377.     }
  1378.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerPhpFileLoader $loader)
  1379.     {
  1380.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1381.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1382.         }
  1383.         $loader->load('property_info.php');
  1384.         if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) {
  1385.             $definition $container->register('property_info.php_doc_extractor''Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
  1386.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1387.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1388.         }
  1389.         if ($container->getParameter('kernel.debug')) {
  1390.             $container->removeDefinition('property_info.cache');
  1391.         }
  1392.     }
  1393.     private function registerLockConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1394.     {
  1395.         $loader->load('lock.php');
  1396.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1397.             if (=== \count($resourceStores)) {
  1398.                 continue;
  1399.             }
  1400.             // Generate stores
  1401.             $storeDefinitions = [];
  1402.             foreach ($resourceStores as $storeDsn) {
  1403.                 $storeDsn $container->resolveEnvPlaceholders($storeDsnnull$usedEnvs);
  1404.                 $storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class);
  1405.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1406.                 $storeDefinition->setArguments([$storeDsn]);
  1407.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1408.                 $storeDefinition = new Reference($storeDefinitionId);
  1409.                 $storeDefinitions[] = $storeDefinition;
  1410.             }
  1411.             // Wrap array of stores with CombinedStore
  1412.             if (\count($storeDefinitions) > 1) {
  1413.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1414.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1415.                 $container->setDefinition('lock.'.$resourceName.'.store'$combinedDefinition)->setDeprecated('symfony/framework-bundle''5.2''The "%service_id%" service is deprecated, use "lock.'.$resourceName.'.factory" instead.');
  1416.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($resourceStores), $combinedDefinition);
  1417.             } else {
  1418.                 $container->setAlias('lock.'.$resourceName.'.store', (new Alias($storeDefinitionIdfalse))->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "lock.'.$resourceName.'.factory" instead.'));
  1419.             }
  1420.             // Generate factories for each resource
  1421.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1422.             $factoryDefinition->replaceArgument(0, new Reference($storeDefinitionId));
  1423.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1424.             // Generate services for lock instances
  1425.             $lockDefinition = new Definition(Lock::class);
  1426.             $lockDefinition->setPublic(false);
  1427.             $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
  1428.             $lockDefinition->setArguments([$resourceName]);
  1429.             $container->setDefinition('lock.'.$resourceName$lockDefinition)->setDeprecated('symfony/framework-bundle''5.2''The "%service_id%" service is deprecated, use "lock.'.$resourceName.'.factory" instead.');
  1430.             // provide alias for default resource
  1431.             if ('default' === $resourceName) {
  1432.                 $container->setAlias('lock.store', (new Alias($storeDefinitionIdfalse))->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "lock.factory" instead.'));
  1433.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1434.                 $container->setAlias('lock', (new Alias('lock.'.$resourceNamefalse))->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "lock.factory" instead.'));
  1435.                 $container->setAlias(PersistingStoreInterface::class, (new Alias($storeDefinitionIdfalse))->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "'.LockFactory::class.'" instead.'));
  1436.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1437.                 $container->setAlias(LockInterface::class, (new Alias('lock.'.$resourceNamefalse))->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "'.LockFactory::class.'" instead.'));
  1438.             } else {
  1439.                 $container->registerAliasForArgument($storeDefinitionIdPersistingStoreInterface::class, $resourceName.'.lock.store')->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "'.LockFactory::class.' '.$resourceName.'LockFactory" instead.');
  1440.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1441.                 $container->registerAliasForArgument('lock.'.$resourceNameLockInterface::class, $resourceName.'.lock')->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "'.LockFactory::class.' $'.$resourceName.'LockFactory" instead.');
  1442.             }
  1443.         }
  1444.     }
  1445.     private function registerMessengerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader, array $validationConfig)
  1446.     {
  1447.         if (!interface_exists(MessageBusInterface::class)) {
  1448.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1449.         }
  1450.         $loader->load('messenger.php');
  1451.         if (class_exists(AmqpTransportFactory::class)) {
  1452.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1453.         }
  1454.         if (class_exists(RedisTransportFactory::class)) {
  1455.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1456.         }
  1457.         if (class_exists(AmazonSqsTransportFactory::class)) {
  1458.             $container->getDefinition('messenger.transport.sqs.factory')->addTag('messenger.transport_factory');
  1459.         }
  1460.         if (class_exists(BeanstalkdTransportFactory::class)) {
  1461.             $container->getDefinition('messenger.transport.beanstalkd.factory')->addTag('messenger.transport_factory');
  1462.         }
  1463.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1464.             $config['default_bus'] = key($config['buses']);
  1465.         }
  1466.         $defaultMiddleware = [
  1467.             'before' => [
  1468.                 ['id' => 'add_bus_name_stamp_middleware'],
  1469.                 ['id' => 'reject_redelivered_message_middleware'],
  1470.                 ['id' => 'dispatch_after_current_bus'],
  1471.                 ['id' => 'failed_message_processing_middleware'],
  1472.             ],
  1473.             'after' => [
  1474.                 ['id' => 'send_message'],
  1475.                 ['id' => 'handle_message'],
  1476.             ],
  1477.         ];
  1478.         foreach ($config['buses'] as $busId => $bus) {
  1479.             $middleware $bus['middleware'];
  1480.             if ($bus['default_middleware']) {
  1481.                 if ('allow_no_handlers' === $bus['default_middleware']) {
  1482.                     $defaultMiddleware['after'][1]['arguments'] = [true];
  1483.                 } else {
  1484.                     unset($defaultMiddleware['after'][1]['arguments']);
  1485.                 }
  1486.                 // argument to add_bus_name_stamp_middleware
  1487.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1488.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1489.             }
  1490.             foreach ($middleware as $middlewareItem) {
  1491.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1492.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1493.                 }
  1494.             }
  1495.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1496.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1497.             }
  1498.             $container->setParameter($busId.'.middleware'$middleware);
  1499.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1500.             if ($busId === $config['default_bus']) {
  1501.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1502.                 $container->setAlias(MessageBusInterface::class, $busId);
  1503.             } else {
  1504.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1505.             }
  1506.         }
  1507.         if (empty($config['transports'])) {
  1508.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1509.             $container->removeDefinition('messenger.transport.amqp.factory');
  1510.             $container->removeDefinition('messenger.transport.redis.factory');
  1511.             $container->removeDefinition('messenger.transport.sqs.factory');
  1512.             $container->removeDefinition('messenger.transport.beanstalkd.factory');
  1513.             $container->removeAlias(SerializerInterface::class);
  1514.         } else {
  1515.             $container->getDefinition('messenger.transport.symfony_serializer')
  1516.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1517.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1518.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1519.         }
  1520.         $senderAliases = [];
  1521.         $transportRetryReferences = [];
  1522.         foreach ($config['transports'] as $name => $transport) {
  1523.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1524.             $transportDefinition = (new Definition(TransportInterface::class))
  1525.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1526.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1527.                 ->addTag('messenger.receiver', ['alias' => $name])
  1528.             ;
  1529.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1530.             $senderAliases[$name] = $transportId;
  1531.             if (null !== $transport['retry_strategy']['service']) {
  1532.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1533.             } else {
  1534.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1535.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1536.                 $retryDefinition
  1537.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1538.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1539.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1540.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1541.                 $container->setDefinition($retryServiceId$retryDefinition);
  1542.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1543.             }
  1544.         }
  1545.         $senderReferences = [];
  1546.         // alias => service_id
  1547.         foreach ($senderAliases as $alias => $serviceId) {
  1548.             $senderReferences[$alias] = new Reference($serviceId);
  1549.         }
  1550.         // service_id => service_id
  1551.         foreach ($senderAliases as $serviceId) {
  1552.             $senderReferences[$serviceId] = new Reference($serviceId);
  1553.         }
  1554.         $messageToSendersMapping = [];
  1555.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1556.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1557.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1558.             }
  1559.             // make sure senderAliases contains all senders
  1560.             foreach ($messageConfiguration['senders'] as $sender) {
  1561.                 if (!isset($senderReferences[$sender])) {
  1562.                     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));
  1563.                 }
  1564.             }
  1565.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1566.         }
  1567.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1568.         $container->getDefinition('messenger.senders_locator')
  1569.             ->replaceArgument(0$messageToSendersMapping)
  1570.             ->replaceArgument(1$sendersServiceLocator)
  1571.         ;
  1572.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1573.             ->replaceArgument(0$sendersServiceLocator)
  1574.         ;
  1575.         $container->getDefinition('messenger.retry_strategy_locator')
  1576.             ->replaceArgument(0$transportRetryReferences);
  1577.         if ($config['failure_transport']) {
  1578.             if (!isset($senderReferences[$config['failure_transport']])) {
  1579.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1580.             }
  1581.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1582.                 ->replaceArgument(0$senderReferences[$config['failure_transport']]);
  1583.             $container->getDefinition('console.command.messenger_failed_messages_retry')
  1584.                 ->replaceArgument(0$config['failure_transport']);
  1585.             $container->getDefinition('console.command.messenger_failed_messages_show')
  1586.                 ->replaceArgument(0$config['failure_transport']);
  1587.             $container->getDefinition('console.command.messenger_failed_messages_remove')
  1588.                 ->replaceArgument(0$config['failure_transport']);
  1589.         } else {
  1590.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1591.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1592.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1593.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1594.         }
  1595.     }
  1596.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1597.     {
  1598.         if (!class_exists(DefaultMarshaller::class)) {
  1599.             $container->removeDefinition('cache.default_marshaller');
  1600.         }
  1601.         $version = new Parameter('container.build_id');
  1602.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1603.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1604.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1605.         if (isset($config['prefix_seed'])) {
  1606.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1607.         }
  1608.         if ($container->hasParameter('cache.prefix.seed')) {
  1609.             // Inline any env vars referenced in the parameter
  1610.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1611.         }
  1612.         foreach (['doctrine''psr6''redis''memcached''pdo'] as $name) {
  1613.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1614.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1615.             }
  1616.         }
  1617.         foreach (['app''system'] as $name) {
  1618.             $config['pools']['cache.'.$name] = [
  1619.                 'adapters' => [$config[$name]],
  1620.                 'public' => true,
  1621.                 'tags' => false,
  1622.             ];
  1623.         }
  1624.         foreach ($config['pools'] as $name => $pool) {
  1625.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1626.             $isRedisTagAware = ['cache.adapter.redis_tag_aware'] === $pool['adapters'];
  1627.             foreach ($pool['adapters'] as $provider => $adapter) {
  1628.                 if (($config['pools'][$adapter]['adapters'] ?? null) === ['cache.adapter.redis_tag_aware']) {
  1629.                     $isRedisTagAware true;
  1630.                 } elseif ($config['pools'][$adapter]['tags'] ?? false) {
  1631.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1632.                 }
  1633.             }
  1634.             if (=== \count($pool['adapters'])) {
  1635.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1636.                     $pool['provider'] = $provider;
  1637.                 }
  1638.                 $definition = new ChildDefinition($adapter);
  1639.             } else {
  1640.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1641.                 $pool['reset'] = 'reset';
  1642.             }
  1643.             if ($isRedisTagAware) {
  1644.                 $tagAwareId $name;
  1645.                 $container->setAlias('.'.$name.'.inner'$name);
  1646.             } elseif ($pool['tags']) {
  1647.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1648.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1649.                 }
  1650.                 $container->register($nameTagAwareAdapter::class)
  1651.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1652.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1653.                     ->setPublic($pool['public'])
  1654.                 ;
  1655.                 $pool['name'] = $tagAwareId $name;
  1656.                 $pool['public'] = false;
  1657.                 $name '.'.$name.'.inner';
  1658.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1659.                 $tagAwareId '.'.$name.'.taggable';
  1660.                 $container->register($tagAwareIdTagAwareAdapter::class)
  1661.                     ->addArgument(new Reference($name))
  1662.                 ;
  1663.             }
  1664.             if (!\in_array($name, ['cache.app''cache.system'], true)) {
  1665.                 $container->registerAliasForArgument($tagAwareIdTagAwareCacheInterface::class, $pool['name'] ?? $name);
  1666.                 $container->registerAliasForArgument($nameCacheInterface::class, $pool['name'] ?? $name);
  1667.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name'] ?? $name);
  1668.             }
  1669.             $definition->setPublic($pool['public']);
  1670.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1671.             $definition->addTag('cache.pool'$pool);
  1672.             $container->setDefinition($name$definition);
  1673.         }
  1674.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1675.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1676.             $propertyAccessDefinition->setPublic(false);
  1677.             if (!$container->getParameter('kernel.debug')) {
  1678.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1679.                 $propertyAccessDefinition->setArguments([null0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1680.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1681.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1682.             } else {
  1683.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1684.                 $propertyAccessDefinition->setArguments([0false]);
  1685.             }
  1686.         }
  1687.     }
  1688.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader, array $profilerConfig)
  1689.     {
  1690.         $loader->load('http_client.php');
  1691.         $options $config['default_options'] ?? [];
  1692.         $retryOptions $options['retry_failed'] ?? ['enabled' => false];
  1693.         unset($options['retry_failed']);
  1694.         $container->getDefinition('http_client')->setArguments([$options$config['max_host_connections'] ?? 6]);
  1695.         if (!$hasPsr18 interface_exists(ClientInterface::class)) {
  1696.             $container->removeDefinition('psr18.http_client');
  1697.             $container->removeAlias(ClientInterface::class);
  1698.         }
  1699.         if (!interface_exists(HttpClient::class)) {
  1700.             $container->removeDefinition(HttpClient::class);
  1701.         }
  1702.         if ($this->isConfigEnabled($container$retryOptions)) {
  1703.             $this->registerRetryableHttpClient($retryOptions'http_client'$container);
  1704.         }
  1705.         $httpClientId = ($retryOptions['enabled'] ?? false) ? 'http_client.retryable.inner' : ($this->isConfigEnabled($container$profilerConfig) ? '.debug.http_client.inner' 'http_client');
  1706.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1707.             if ('http_client' === $name) {
  1708.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1709.             }
  1710.             $scope $scopeConfig['scope'] ?? null;
  1711.             unset($scopeConfig['scope']);
  1712.             $retryOptions $scopeConfig['retry_failed'] ?? ['enabled' => false];
  1713.             unset($scopeConfig['retry_failed']);
  1714.             if (null === $scope) {
  1715.                 $baseUri $scopeConfig['base_uri'];
  1716.                 unset($scopeConfig['base_uri']);
  1717.                 $container->register($nameScopingHttpClient::class)
  1718.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1719.                     ->setArguments([new Reference($httpClientId), $baseUri$scopeConfig])
  1720.                     ->addTag('http_client.client')
  1721.                 ;
  1722.             } else {
  1723.                 $container->register($nameScopingHttpClient::class)
  1724.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1725.                     ->addTag('http_client.client')
  1726.                 ;
  1727.             }
  1728.             if ($this->isConfigEnabled($container$retryOptions)) {
  1729.                 $this->registerRetryableHttpClient($retryOptions$name$container);
  1730.             }
  1731.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  1732.             if ($hasPsr18) {
  1733.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  1734.                     ->replaceArgument(0, new Reference($name));
  1735.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  1736.             }
  1737.         }
  1738.         if ($responseFactoryId $config['mock_response_factory'] ?? null) {
  1739.             $container->register($httpClientId.'.mock_client'MockHttpClient::class)
  1740.                 ->setDecoratedService($httpClientIdnull, -10// lower priority than TraceableHttpClient
  1741.                 ->setArguments([new Reference($responseFactoryId)]);
  1742.         }
  1743.     }
  1744.     private function registerRetryableHttpClient(array $optionsstring $nameContainerBuilder $container)
  1745.     {
  1746.         if (!class_exists(RetryableHttpClient::class)) {
  1747.             throw new LogicException('Support for retrying failed requests requires symfony/http-client 5.2 or higher, try upgrading.');
  1748.         }
  1749.         if (null !== $options['retry_strategy']) {
  1750.             $retryStrategy = new Reference($options['retry_strategy']);
  1751.         } else {
  1752.             $retryStrategy = new ChildDefinition('http_client.abstract_retry_strategy');
  1753.             $codes = [];
  1754.             foreach ($options['http_codes'] as $code => $codeOptions) {
  1755.                 if ($codeOptions['methods']) {
  1756.                     $codes[$code] = $codeOptions['methods'];
  1757.                 } else {
  1758.                     $codes[] = $code;
  1759.                 }
  1760.             }
  1761.             $retryStrategy
  1762.                 ->replaceArgument(0$codes ?: GenericRetryStrategy::DEFAULT_RETRY_STATUS_CODES)
  1763.                 ->replaceArgument(1$options['delay'])
  1764.                 ->replaceArgument(2$options['multiplier'])
  1765.                 ->replaceArgument(3$options['max_delay'])
  1766.                 ->replaceArgument(4$options['jitter']);
  1767.             $container->setDefinition($name.'.retry_strategy'$retryStrategy);
  1768.             $retryStrategy = new Reference($name.'.retry_strategy');
  1769.         }
  1770.         $container
  1771.             ->register($name.'.retryable'RetryableHttpClient::class)
  1772.             ->setDecoratedService($namenull10// higher priority than TraceableHttpClient
  1773.             ->setArguments([new Reference($name.'.retryable.inner'), $retryStrategy$options['max_retries'], new Reference('logger')])
  1774.             ->addTag('monolog.logger', ['channel' => 'http_client']);
  1775.     }
  1776.     private function registerMailerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1777.     {
  1778.         if (!class_exists(Mailer::class)) {
  1779.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  1780.         }
  1781.         $loader->load('mailer.php');
  1782.         $loader->load('mailer_transports.php');
  1783.         if (!\count($config['transports']) && null === $config['dsn']) {
  1784.             $config['dsn'] = 'smtp://null';
  1785.         }
  1786.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  1787.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  1788.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  1789.         $container->removeDefinition('mailer.logger_message_listener');
  1790.         $container->setAlias('mailer.logger_message_listener', (new Alias('mailer.message_logger_listener'))->setDeprecated('symfony/framework-bundle''5.2''The "%alias_id%" alias is deprecated, use "mailer.message_logger_listener" instead.'));
  1791.         $mailer $container->getDefinition('mailer.mailer');
  1792.         if (false === $messageBus $config['message_bus']) {
  1793.             $mailer->replaceArgument(1null);
  1794.         } else {
  1795.             $mailer->replaceArgument(1$messageBus ? new Reference($messageBus) : new Reference('messenger.default_bus'ContainerInterface::NULL_ON_INVALID_REFERENCE));
  1796.         }
  1797.         $classToServices = [
  1798.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  1799.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  1800.             MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
  1801.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  1802.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  1803.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  1804.             SendinblueTransportFactory::class => 'mailer.transport_factory.sendinblue',
  1805.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  1806.         ];
  1807.         foreach ($classToServices as $class => $service) {
  1808.             if (!class_exists($class)) {
  1809.                 $container->removeDefinition($service);
  1810.             }
  1811.         }
  1812.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  1813.         $envelopeListener->setArgument(0$config['envelope']['sender'] ?? null);
  1814.         $envelopeListener->setArgument(1$config['envelope']['recipients'] ?? null);
  1815.         if ($config['headers']) {
  1816.             $headers = new Definition(Headers::class);
  1817.             foreach ($config['headers'] as $name => $data) {
  1818.                 $value $data['value'];
  1819.                 if (\in_array(strtolower($name), ['from''to''cc''bcc''reply-to'])) {
  1820.                     $value = (array) $value;
  1821.                 }
  1822.                 $headers->addMethodCall('addHeader', [$name$value]);
  1823.             }
  1824.             $messageListener $container->getDefinition('mailer.message_listener');
  1825.             $messageListener->setArgument(0$headers);
  1826.         } else {
  1827.             $container->removeDefinition('mailer.message_listener');
  1828.         }
  1829.     }
  1830.     private function registerNotifierConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1831.     {
  1832.         if (!class_exists(Notifier::class)) {
  1833.             throw new LogicException('Notifier support cannot be enabled as the component is not installed. Try running "composer require symfony/notifier".');
  1834.         }
  1835.         $loader->load('notifier.php');
  1836.         $loader->load('notifier_transports.php');
  1837.         if ($config['chatter_transports']) {
  1838.             $container->getDefinition('chatter.transports')->setArgument(0$config['chatter_transports']);
  1839.         } else {
  1840.             $container->removeDefinition('chatter');
  1841.         }
  1842.         if ($config['texter_transports']) {
  1843.             $container->getDefinition('texter.transports')->setArgument(0$config['texter_transports']);
  1844.         } else {
  1845.             $container->removeDefinition('texter');
  1846.         }
  1847.         if ($this->mailerConfigEnabled) {
  1848.             $sender $container->getDefinition('mailer.envelope_listener')->getArgument(0);
  1849.             $container->getDefinition('notifier.channel.email')->setArgument(2$sender);
  1850.         } else {
  1851.             $container->removeDefinition('notifier.channel.email');
  1852.         }
  1853.         if ($this->messengerConfigEnabled) {
  1854.             if ($config['notification_on_failed_messages']) {
  1855.                 $container->getDefinition('notifier.failed_message_listener')->addTag('kernel.event_subscriber');
  1856.             }
  1857.             // as we have a bus, the channels don't need the transports
  1858.             $container->getDefinition('notifier.channel.chat')->setArgument(0null);
  1859.             if ($container->hasDefinition('notifier.channel.email')) {
  1860.                 $container->getDefinition('notifier.channel.email')->setArgument(0null);
  1861.             }
  1862.             $container->getDefinition('notifier.channel.sms')->setArgument(0null);
  1863.         }
  1864.         $container->getDefinition('notifier.channel_policy')->setArgument(0$config['channel_policy']);
  1865.         $classToServices = [
  1866.             SlackTransportFactory::class => 'notifier.transport_factory.slack',
  1867.             TelegramTransportFactory::class => 'notifier.transport_factory.telegram',
  1868.             MattermostTransportFactory::class => 'notifier.transport_factory.mattermost',
  1869.             GoogleChatTransportFactory::class => 'notifier.transport_factory.googlechat',
  1870.             NexmoTransportFactory::class => 'notifier.transport_factory.nexmo',
  1871.             RocketChatTransportFactory::class => 'notifier.transport_factory.rocketchat',
  1872.             InfobipTransportFactory::class => 'notifier.transport_factory.infobip',
  1873.             TwilioTransportFactory::class => 'notifier.transport_factory.twilio',
  1874.             FirebaseTransportFactory::class => 'notifier.transport_factory.firebase',
  1875.             FreeMobileTransportFactory::class => 'notifier.transport_factory.freemobile',
  1876.             OvhCloudTransportFactory::class => 'notifier.transport_factory.ovhcloud',
  1877.             SinchTransportFactory::class => 'notifier.transport_factory.sinch',
  1878.             ZulipTransportFactory::class => 'notifier.transport_factory.zulip',
  1879.             MobytTransportFactory::class => 'notifier.transport_factory.mobyt',
  1880.             SmsapiTransportFactory::class => 'notifier.transport_factory.smsapi',
  1881.             EsendexTransportFactory::class => 'notifier.transport_factory.esendex',
  1882.             SendinblueNotifierTransportFactory::class => 'notifier.transport_factory.sendinblue',
  1883.             DiscordTransportFactory::class => 'notifier.transport_factory.discord',
  1884.             LinkedInTransportFactory::class => 'notifier.transport_factory.linkedin',
  1885.         ];
  1886.         foreach ($classToServices as $class => $service) {
  1887.             if (!class_exists($class)) {
  1888.                 $container->removeDefinition($service);
  1889.             }
  1890.         }
  1891.         if (isset($config['admin_recipients'])) {
  1892.             $notifier $container->getDefinition('notifier');
  1893.             foreach ($config['admin_recipients'] as $i => $recipient) {
  1894.                 $id 'notifier.admin_recipient.'.$i;
  1895.                 $container->setDefinition($id, new Definition(Recipient::class, [$recipient['email'], $recipient['phone']]));
  1896.                 $notifier->addMethodCall('addAdminRecipient', [new Reference($id)]);
  1897.             }
  1898.         }
  1899.     }
  1900.     private function registerRateLimiterConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1901.     {
  1902.         if (!$this->lockConfigEnabled) {
  1903.             throw new LogicException('Rate limiter support cannot be enabled without enabling the Lock component.');
  1904.         }
  1905.         $loader->load('rate_limiter.php');
  1906.         foreach ($config['limiters'] as $name => $limiterConfig) {
  1907.             self::registerRateLimiter($container$name$limiterConfig);
  1908.         }
  1909.     }
  1910.     public static function registerRateLimiter(ContainerBuilder $containerstring $name, array $limiterConfig)
  1911.     {
  1912.         // default configuration (when used by other DI extensions)
  1913.         $limiterConfig += ['lock_factory' => 'lock.factory''cache_pool' => 'cache.rate_limiter'];
  1914.         $limiter $container->setDefinition($limiterId 'limiter.'.$name, new ChildDefinition('limiter'));
  1915.         $limiter->addArgument(new Reference($limiterConfig['lock_factory']));
  1916.         unset($limiterConfig['lock_factory']);
  1917.         $storageId $limiterConfig['storage_service'] ?? null;
  1918.         if (null === $storageId) {
  1919.             $container->register($storageId 'limiter.storage.'.$nameCacheStorage::class)->addArgument(new Reference($limiterConfig['cache_pool']));
  1920.         }
  1921.         $limiter->replaceArgument(1, new Reference($storageId));
  1922.         unset($limiterConfig['storage_service']);
  1923.         unset($limiterConfig['cache_pool']);
  1924.         $limiterConfig['id'] = $name;
  1925.         $limiter->replaceArgument(0$limiterConfig);
  1926.         $container->registerAliasForArgument($limiterIdRateLimiterFactory::class, $name.'.limiter');
  1927.     }
  1928.     private function resolveTrustedHeaders(array $headers): int
  1929.     {
  1930.         $trustedHeaders 0;
  1931.         foreach ($headers as $h) {
  1932.             switch ($h) {
  1933.                 case 'forwarded'$trustedHeaders |= Request::HEADER_FORWARDED; break;
  1934.                 case 'x-forwarded-for'$trustedHeaders |= Request::HEADER_X_FORWARDED_FOR; break;
  1935.                 case 'x-forwarded-host'$trustedHeaders |= Request::HEADER_X_FORWARDED_HOST; break;
  1936.                 case 'x-forwarded-proto'$trustedHeaders |= Request::HEADER_X_FORWARDED_PROTO; break;
  1937.                 case 'x-forwarded-port'$trustedHeaders |= Request::HEADER_X_FORWARDED_PORT; break;
  1938.                 case 'x-forwarded-prefix'$trustedHeaders |= Request::HEADER_X_FORWARDED_PREFIX; break;
  1939.             }
  1940.         }
  1941.         return $trustedHeaders;
  1942.     }
  1943.     /**
  1944.      * {@inheritdoc}
  1945.      */
  1946.     public function getXsdValidationBasePath()
  1947.     {
  1948.         return \dirname(__DIR__).'/Resources/config/schema';
  1949.     }
  1950.     public function getNamespace()
  1951.     {
  1952.         return 'http://symfony.com/schema/dic/symfony';
  1953.     }
  1954. }