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

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