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

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