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