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

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