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

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