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

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