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.             if (isset($workflow['marking_store']['type'])) {
  849.                 $markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
  850.                 $markingStoreDefinition->setArguments([
  851.                     'state_machine' === $type// single state
  852.                     $workflow['marking_store']['property'],
  853.                 ]);
  854.             } elseif (isset($workflow['marking_store']['service'])) {
  855.                 $markingStoreDefinition = new Reference($workflow['marking_store']['service']);
  856.             }
  857.             // Create Workflow
  858.             $workflowDefinition = new ChildDefinition(sprintf('%s.abstract'$type));
  859.             $workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition'$workflowId)));
  860.             $workflowDefinition->replaceArgument(1$markingStoreDefinition ?? null);
  861.             $workflowDefinition->replaceArgument(3$name);
  862.             $workflowDefinition->replaceArgument(4$workflow['events_to_dispatch']);
  863.             $workflowDefinition->addTag('workflow', ['name' => $name]);
  864.             if ('workflow' === $type) {
  865.                 $workflowDefinition->addTag('workflow.workflow', ['name' => $name]);
  866.             } elseif ('state_machine' === $type) {
  867.                 $workflowDefinition->addTag('workflow.state_machine', ['name' => $name]);
  868.             }
  869.             // Store to container
  870.             $container->setDefinition($workflowId$workflowDefinition);
  871.             $container->setDefinition(sprintf('%s.definition'$workflowId), $definitionDefinition);
  872.             $container->registerAliasForArgument($workflowIdWorkflowInterface::class, $name.'.'.$type);
  873.             // Validate Workflow
  874.             if ('state_machine' === $workflow['type']) {
  875.                 $validator = new Workflow\Validator\StateMachineValidator();
  876.             } else {
  877.                 $validator = new Workflow\Validator\WorkflowValidator();
  878.             }
  879.             $trs array_map(function (Reference $ref) use ($container): Workflow\Transition {
  880.                 return $container->get((string) $ref);
  881.             }, $transitions);
  882.             $realDefinition = new Workflow\Definition($places$trs$initialMarking);
  883.             $validator->validate($realDefinition$name);
  884.             // Add workflow to Registry
  885.             if ($workflow['supports']) {
  886.                 foreach ($workflow['supports'] as $supportedClassName) {
  887.                     $strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, [$supportedClassName]);
  888.                     $strategyDefinition->setPublic(false);
  889.                     $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
  890.                 }
  891.             } elseif (isset($workflow['support_strategy'])) {
  892.                 $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), new Reference($workflow['support_strategy'])]);
  893.             }
  894.             // Enable the AuditTrail
  895.             if ($workflow['audit_trail']['enabled']) {
  896.                 $listener = new Definition(Workflow\EventListener\AuditTrailListener::class);
  897.                 $listener->addTag('monolog.logger', ['channel' => 'workflow']);
  898.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave'$name), 'method' => 'onLeave']);
  899.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition'$name), 'method' => 'onTransition']);
  900.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter'$name), 'method' => 'onEnter']);
  901.                 $listener->addArgument(new Reference('logger'));
  902.                 $container->setDefinition(sprintf('.%s.listener.audit_trail'$workflowId), $listener);
  903.             }
  904.             // Add Guard Listener
  905.             if ($guardsConfiguration) {
  906.                 if (!class_exists(ExpressionLanguage::class)) {
  907.                     throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
  908.                 }
  909.                 if (!class_exists(AuthenticationEvents::class)) {
  910.                     throw new LogicException('Cannot guard workflows as the Security component is not installed. Try running "composer require symfony/security-core".');
  911.                 }
  912.                 $guard = new Definition(Workflow\EventListener\GuardListener::class);
  913.                 $guard->setArguments([
  914.                     $guardsConfiguration,
  915.                     new Reference('workflow.security.expression_language'),
  916.                     new Reference('security.token_storage'),
  917.                     new Reference('security.authorization_checker'),
  918.                     new Reference('security.authentication.trust_resolver'),
  919.                     new Reference('security.role_hierarchy'),
  920.                     new Reference('validator'ContainerInterface::NULL_ON_INVALID_REFERENCE),
  921.                 ]);
  922.                 foreach ($guardsConfiguration as $eventName => $config) {
  923.                     $guard->addTag('kernel.event_listener', ['event' => $eventName'method' => 'onTransition']);
  924.                 }
  925.                 $container->setDefinition(sprintf('.%s.listener.guard'$workflowId), $guard);
  926.                 $container->setParameter('workflow.has_guard_listeners'true);
  927.             }
  928.         }
  929.     }
  930.     private function registerDebugConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  931.     {
  932.         $loader->load('debug_prod.php');
  933.         if (class_exists(Stopwatch::class)) {
  934.             $container->register('debug.stopwatch'Stopwatch::class)
  935.                 ->addArgument(true)
  936.                 ->addTag('kernel.reset', ['method' => 'reset']);
  937.             $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch'false));
  938.         }
  939.         $debug $container->getParameter('kernel.debug');
  940.         if ($debug) {
  941.             $container->setParameter('debug.container.dump''%kernel.build_dir%/%kernel.container_class%.xml');
  942.         }
  943.         if ($debug && class_exists(Stopwatch::class)) {
  944.             $loader->load('debug.php');
  945.         }
  946.         $definition $container->findDefinition('debug.debug_handlers_listener');
  947.         if (false === $config['log']) {
  948.             $definition->replaceArgument(1null);
  949.         } elseif (true !== $config['log']) {
  950.             $definition->replaceArgument(2$config['log']);
  951.         }
  952.         if (!$config['throw']) {
  953.             $container->setParameter('debug.error_handler.throw_at'0);
  954.         }
  955.         if ($debug && class_exists(DebugProcessor::class)) {
  956.             $definition = new Definition(DebugProcessor::class);
  957.             $definition->setPublic(false);
  958.             $definition->addArgument(new Reference('request_stack'));
  959.             $container->setDefinition('debug.log_processor'$definition);
  960.         }
  961.     }
  962.     private function registerRouterConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader, array $enabledLocales = [])
  963.     {
  964.         if (!$this->readConfigEnabled('router'$container$config)) {
  965.             $container->removeDefinition('console.command.router_debug');
  966.             $container->removeDefinition('console.command.router_match');
  967.             $container->removeDefinition('messenger.middleware.router_context');
  968.             return;
  969.         }
  970.         if (!class_exists(RouterContextMiddleware::class)) {
  971.             $container->removeDefinition('messenger.middleware.router_context');
  972.         }
  973.         $loader->load('routing.php');
  974.         if ($config['utf8']) {
  975.             $container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
  976.         }
  977.         if ($enabledLocales) {
  978.             $enabledLocales implode('|'array_map('preg_quote'$enabledLocales));
  979.             $container->getDefinition('routing.loader')->replaceArgument(2, ['_locale' => $enabledLocales]);
  980.         }
  981.         if (!ContainerBuilder::willBeAvailable('symfony/expression-language'ExpressionLanguage::class, ['symfony/framework-bundle''symfony/routing'])) {
  982.             $container->removeDefinition('router.expression_language_provider');
  983.         }
  984.         $container->setParameter('router.resource'$config['resource']);
  985.         $container->setParameter('router.cache_dir'$config['cache_dir']);
  986.         $router $container->findDefinition('router.default');
  987.         $argument $router->getArgument(2);
  988.         $argument['strict_requirements'] = $config['strict_requirements'];
  989.         if (isset($config['type'])) {
  990.             $argument['resource_type'] = $config['type'];
  991.         }
  992.         $router->replaceArgument(2$argument);
  993.         $container->setParameter('request_listener.http_port'$config['http_port']);
  994.         $container->setParameter('request_listener.https_port'$config['https_port']);
  995.         if (null !== $config['default_uri']) {
  996.             $container->getDefinition('router.request_context')
  997.                 ->replaceArgument(0$config['default_uri']);
  998.         }
  999.         if (!class_exists(Psr4DirectoryLoader::class)) {
  1000.             $container->removeDefinition('routing.loader.psr4');
  1001.         }
  1002.     }
  1003.     private function registerSessionConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1004.     {
  1005.         $loader->load('session.php');
  1006.         // session storage
  1007.         $container->setAlias('session.storage.factory'$config['storage_factory_id']);
  1008.         $options = ['cache_limiter' => '0'];
  1009.         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) {
  1010.             if (isset($config[$key])) {
  1011.                 $options[$key] = $config[$key];
  1012.             }
  1013.         }
  1014.         if ('auto' === ($options['cookie_secure'] ?? null)) {
  1015.             $container->getDefinition('session.storage.factory.native')->replaceArgument(3true);
  1016.             $container->getDefinition('session.storage.factory.php_bridge')->replaceArgument(2true);
  1017.         }
  1018.         $container->setParameter('session.storage.options'$options);
  1019.         // session handler (the internal callback registered with PHP session management)
  1020.         if (null === $config['handler_id']) {
  1021.             // Set the handler class to be null
  1022.             $container->getDefinition('session.storage.factory.native')->replaceArgument(1null);
  1023.             $container->getDefinition('session.storage.factory.php_bridge')->replaceArgument(0null);
  1024.             $container->setAlias('session.handler''session.handler.native_file');
  1025.         } else {
  1026.             $container->resolveEnvPlaceholders($config['handler_id'], null$usedEnvs);
  1027.             if ($usedEnvs || preg_match('#^[a-z]++://#'$config['handler_id'])) {
  1028.                 $id '.cache_connection.'.ContainerBuilder::hash($config['handler_id']);
  1029.                 $container->getDefinition('session.abstract_handler')
  1030.                     ->replaceArgument(0$container->hasDefinition($id) ? new Reference($id) : $config['handler_id']);
  1031.                 $container->setAlias('session.handler''session.abstract_handler');
  1032.             } else {
  1033.                 $container->setAlias('session.handler'$config['handler_id']);
  1034.             }
  1035.         }
  1036.         $container->setParameter('session.save_path'$config['save_path']);
  1037.         $container->setParameter('session.metadata.update_threshold'$config['metadata_update_threshold']);
  1038.     }
  1039.     private function registerRequestConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1040.     {
  1041.         if ($config['formats']) {
  1042.             $loader->load('request.php');
  1043.             $listener $container->getDefinition('request.add_request_formats_listener');
  1044.             $listener->replaceArgument(0$config['formats']);
  1045.         }
  1046.     }
  1047.     private function registerAssetsConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1048.     {
  1049.         $loader->load('assets.php');
  1050.         if ($config['version_strategy']) {
  1051.             $defaultVersion = new Reference($config['version_strategy']);
  1052.         } else {
  1053.             $defaultVersion $this->createVersion($container$config['version'], $config['version_format'], $config['json_manifest_path'], '_default'$config['strict_mode']);
  1054.         }
  1055.         $defaultPackage $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
  1056.         $container->setDefinition('assets._default_package'$defaultPackage);
  1057.         foreach ($config['packages'] as $name => $package) {
  1058.             if (null !== $package['version_strategy']) {
  1059.                 $version = new Reference($package['version_strategy']);
  1060.             } elseif (!\array_key_exists('version'$package) && null === $package['json_manifest_path']) {
  1061.                 // if neither version nor json_manifest_path are specified, use the default
  1062.                 $version $defaultVersion;
  1063.             } else {
  1064.                 // let format fallback to main version_format
  1065.                 $format $package['version_format'] ?: $config['version_format'];
  1066.                 $version $package['version'] ?? null;
  1067.                 $version $this->createVersion($container$version$format$package['json_manifest_path'], $name$package['strict_mode']);
  1068.             }
  1069.             $packageDefinition $this->createPackageDefinition($package['base_path'], $package['base_urls'], $version)
  1070.                 ->addTag('assets.package', ['package' => $name]);
  1071.             $container->setDefinition('assets._package_'.$name$packageDefinition);
  1072.             $container->registerAliasForArgument('assets._package_'.$namePackageInterface::class, $name.'.package');
  1073.         }
  1074.     }
  1075.     /**
  1076.      * Returns a definition for an asset package.
  1077.      */
  1078.     private function createPackageDefinition(?string $basePath, array $baseUrlsReference $version): Definition
  1079.     {
  1080.         if ($basePath && $baseUrls) {
  1081.             throw new \LogicException('An asset package cannot have base URLs and base paths.');
  1082.         }
  1083.         $package = new ChildDefinition($baseUrls 'assets.url_package' 'assets.path_package');
  1084.         $package
  1085.             ->setPublic(false)
  1086.             ->replaceArgument(0$baseUrls ?: $basePath)
  1087.             ->replaceArgument(1$version)
  1088.         ;
  1089.         return $package;
  1090.     }
  1091.     private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPathstring $namebool $strictMode): Reference
  1092.     {
  1093.         // Configuration prevents $version and $jsonManifestPath from being set
  1094.         if (null !== $version) {
  1095.             $def = new ChildDefinition('assets.static_version_strategy');
  1096.             $def
  1097.                 ->replaceArgument(0$version)
  1098.                 ->replaceArgument(1$format)
  1099.             ;
  1100.             $container->setDefinition('assets._version_'.$name$def);
  1101.             return new Reference('assets._version_'.$name);
  1102.         }
  1103.         if (null !== $jsonManifestPath) {
  1104.             $def = new ChildDefinition('assets.json_manifest_version_strategy');
  1105.             $def->replaceArgument(0$jsonManifestPath);
  1106.             $def->replaceArgument(2$strictMode);
  1107.             $container->setDefinition('assets._version_'.$name$def);
  1108.             return new Reference('assets._version_'.$name);
  1109.         }
  1110.         return new Reference('assets.empty_version_strategy');
  1111.     }
  1112.     private function registerTranslatorConfiguration(array $configContainerBuilder $containerLoaderInterface $loaderstring $defaultLocale, array $enabledLocales)
  1113.     {
  1114.         if (!$this->readConfigEnabled('translator'$container$config)) {
  1115.             $container->removeDefinition('console.command.translation_debug');
  1116.             $container->removeDefinition('console.command.translation_extract');
  1117.             $container->removeDefinition('console.command.translation_pull');
  1118.             $container->removeDefinition('console.command.translation_push');
  1119.             return;
  1120.         }
  1121.         $loader->load('translation.php');
  1122.         if (!ContainerBuilder::willBeAvailable('symfony/translation'LocaleSwitcher::class, ['symfony/framework-bundle'])) {
  1123.             $container->removeDefinition('translation.locale_switcher');
  1124.         }
  1125.         // don't use ContainerBuilder::willBeAvailable() as these are not needed in production
  1126.         if (interface_exists(Parser::class) && class_exists(PhpAstExtractor::class)) {
  1127.             $container->removeDefinition('translation.extractor.php');
  1128.         } else {
  1129.             $container->removeDefinition('translation.extractor.php_ast');
  1130.         }
  1131.         $loader->load('translation_providers.php');
  1132.         // Use the "real" translator instead of the identity default
  1133.         $container->setAlias('translator''translator.default')->setPublic(true);
  1134.         $container->setAlias('translator.formatter', new Alias($config['formatter'], false));
  1135.         $translator $container->findDefinition('translator.default');
  1136.         $translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
  1137.         $defaultOptions $translator->getArgument(4);
  1138.         $defaultOptions['cache_dir'] = $config['cache_dir'];
  1139.         $translator->setArgument(4$defaultOptions);
  1140.         $translator->setArgument(5$enabledLocales);
  1141.         $container->setParameter('translator.logging'$config['logging']);
  1142.         $container->setParameter('translator.default_path'$config['default_path']);
  1143.         // Discover translation directories
  1144.         $dirs = [];
  1145.         $transPaths = [];
  1146.         $nonExistingDirs = [];
  1147.         if (ContainerBuilder::willBeAvailable('symfony/validator'Validation::class, ['symfony/framework-bundle''symfony/translation'])) {
  1148.             $r = new \ReflectionClass(Validation::class);
  1149.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  1150.         }
  1151.         if (ContainerBuilder::willBeAvailable('symfony/form'Form::class, ['symfony/framework-bundle''symfony/translation'])) {
  1152.             $r = new \ReflectionClass(Form::class);
  1153.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  1154.         }
  1155.         if (ContainerBuilder::willBeAvailable('symfony/security-core'AuthenticationException::class, ['symfony/framework-bundle''symfony/translation'])) {
  1156.             $r = new \ReflectionClass(AuthenticationException::class);
  1157.             $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
  1158.         }
  1159.         $defaultDir $container->getParameterBag()->resolveValue($config['default_path']);
  1160.         foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
  1161.             if ($container->fileExists($dir $bundle['path'].'/Resources/translations') || $container->fileExists($dir $bundle['path'].'/translations')) {
  1162.                 $dirs[] = $dir;
  1163.             } else {
  1164.                 $nonExistingDirs[] = $dir;
  1165.             }
  1166.         }
  1167.         foreach ($config['paths'] as $dir) {
  1168.             if ($container->fileExists($dir)) {
  1169.                 $dirs[] = $transPaths[] = $dir;
  1170.             } else {
  1171.                 throw new \UnexpectedValueException(sprintf('"%s" defined in translator.paths does not exist or is not a directory.'$dir));
  1172.             }
  1173.         }
  1174.         if ($container->hasDefinition('console.command.translation_debug')) {
  1175.             $container->getDefinition('console.command.translation_debug')->replaceArgument(5$transPaths);
  1176.         }
  1177.         if ($container->hasDefinition('console.command.translation_extract')) {
  1178.             $container->getDefinition('console.command.translation_extract')->replaceArgument(6$transPaths);
  1179.         }
  1180.         if (null === $defaultDir) {
  1181.             // allow null
  1182.         } elseif ($container->fileExists($defaultDir)) {
  1183.             $dirs[] = $defaultDir;
  1184.         } else {
  1185.             $nonExistingDirs[] = $defaultDir;
  1186.         }
  1187.         // Register translation resources
  1188.         if ($dirs) {
  1189.             $files = [];
  1190.             foreach ($dirs as $dir) {
  1191.                 $finder Finder::create()
  1192.                     ->followLinks()
  1193.                     ->files()
  1194.                     ->filter(function (\SplFileInfo $file) {
  1195.                         return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  1196.                     })
  1197.                     ->in($dir)
  1198.                     ->sortByName()
  1199.                 ;
  1200.                 foreach ($finder as $file) {
  1201.                     $fileNameParts explode('.'basename($file));
  1202.                     $locale $fileNameParts[\count($fileNameParts) - 2];
  1203.                     if (!isset($files[$locale])) {
  1204.                         $files[$locale] = [];
  1205.                     }
  1206.                     $files[$locale][] = (string) $file;
  1207.                 }
  1208.             }
  1209.             $projectDir $container->getParameter('kernel.project_dir');
  1210.             $options array_merge(
  1211.                 $translator->getArgument(4),
  1212.                 [
  1213.                     'resource_files' => $files,
  1214.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1215.                     'cache_vary' => [
  1216.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1217.                             return str_starts_with($dir$projectDir.'/') ? substr($dir\strlen($projectDir)) : $dir;
  1218.                         }, $scannedDirectories),
  1219.                     ],
  1220.                 ]
  1221.             );
  1222.             $translator->replaceArgument(4$options);
  1223.         }
  1224.         if ($config['pseudo_localization']['enabled']) {
  1225.             $options $config['pseudo_localization'];
  1226.             unset($options['enabled']);
  1227.             $container
  1228.                 ->register('translator.pseudo'PseudoLocalizationTranslator::class)
  1229.                 ->setDecoratedService('translator'null, -1// Lower priority than "translator.data_collector"
  1230.                 ->setArguments([
  1231.                     new Reference('translator.pseudo.inner'),
  1232.                     $options,
  1233.                 ]);
  1234.         }
  1235.         $classToServices = [
  1236.             CrowdinProviderFactory::class => 'translation.provider_factory.crowdin',
  1237.             LocoProviderFactory::class => 'translation.provider_factory.loco',
  1238.             LokaliseProviderFactory::class => 'translation.provider_factory.lokalise',
  1239.         ];
  1240.         $parentPackages = ['symfony/framework-bundle''symfony/translation''symfony/http-client'];
  1241.         foreach ($classToServices as $class => $service) {
  1242.             $package substr($service\strlen('translation.provider_factory.'));
  1243.             if (!$container->hasDefinition('http_client') || !ContainerBuilder::willBeAvailable(sprintf('symfony/%s-translation-provider'$package), $class$parentPackages)) {
  1244.                 $container->removeDefinition($service);
  1245.             }
  1246.         }
  1247.         if (!$config['providers']) {
  1248.             return;
  1249.         }
  1250.         $locales $enabledLocales;
  1251.         foreach ($config['providers'] as $provider) {
  1252.             if ($provider['locales']) {
  1253.                 $locales += $provider['locales'];
  1254.             }
  1255.         }
  1256.         $locales array_unique($locales);
  1257.         $container->getDefinition('console.command.translation_pull')
  1258.             ->replaceArgument(4array_merge($transPaths, [$config['default_path']]))
  1259.             ->replaceArgument(5$locales)
  1260.         ;
  1261.         $container->getDefinition('console.command.translation_push')
  1262.             ->replaceArgument(2array_merge($transPaths, [$config['default_path']]))
  1263.             ->replaceArgument(3$locales)
  1264.         ;
  1265.         $container->getDefinition('translation.provider_collection_factory')
  1266.             ->replaceArgument(1$locales)
  1267.         ;
  1268.         $container->getDefinition('translation.provider_collection')->setArgument(0$config['providers']);
  1269.     }
  1270.     private function registerValidationConfiguration(array $configContainerBuilder $containerPhpFileLoader $loaderbool $propertyInfoEnabled)
  1271.     {
  1272.         if (!$this->readConfigEnabled('validation'$container$config)) {
  1273.             $container->removeDefinition('console.command.validator_debug');
  1274.             return;
  1275.         }
  1276.         if (!class_exists(Validation::class)) {
  1277.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1278.         }
  1279.         if (!isset($config['email_validation_mode'])) {
  1280.             $config['email_validation_mode'] = 'loose';
  1281.         }
  1282.         $loader->load('validator.php');
  1283.         $validatorBuilder $container->getDefinition('validator.builder');
  1284.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1285.         $files = ['xml' => [], 'yml' => []];
  1286.         $this->registerValidatorMapping($container$config$files);
  1287.         if (!empty($files['xml'])) {
  1288.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1289.         }
  1290.         if (!empty($files['yml'])) {
  1291.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1292.         }
  1293.         $definition $container->findDefinition('validator.email');
  1294.         $definition->replaceArgument(0$config['email_validation_mode']);
  1295.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1296.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [true]);
  1297.             if ($this->isInitializedConfigEnabled('annotations')) {
  1298.                 $validatorBuilder->addMethodCall('setDoctrineAnnotationReader', [new Reference('annotation_reader')]);
  1299.             }
  1300.         }
  1301.         if (\array_key_exists('static_method'$config) && $config['static_method']) {
  1302.             foreach ($config['static_method'] as $methodName) {
  1303.                 $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
  1304.             }
  1305.         }
  1306.         if (!$container->getParameter('kernel.debug')) {
  1307.             $validatorBuilder->addMethodCall('setMappingCache', [new Reference('validator.mapping.cache.adapter')]);
  1308.         }
  1309.         $container->setParameter('validator.auto_mapping'$config['auto_mapping']);
  1310.         if (!$propertyInfoEnabled || !class_exists(PropertyInfoLoader::class)) {
  1311.             $container->removeDefinition('validator.property_info_loader');
  1312.         }
  1313.         $container
  1314.             ->getDefinition('validator.not_compromised_password')
  1315.             ->setArgument(2$config['not_compromised_password']['enabled'])
  1316.             ->setArgument(3$config['not_compromised_password']['endpoint'])
  1317.         ;
  1318.         if (!class_exists(ExpressionLanguage::class)) {
  1319.             $container->removeDefinition('validator.expression_language');
  1320.         }
  1321.         if (!class_exists(WhenValidator::class)) {
  1322.             $container->removeDefinition('validator.when');
  1323.         }
  1324.     }
  1325.     private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files)
  1326.     {
  1327.         $fileRecorder = function ($extension$path) use (&$files) {
  1328.             $files['yaml' === $extension 'yml' $extension][] = $path;
  1329.         };
  1330.         if (ContainerBuilder::willBeAvailable('symfony/form'Form::class, ['symfony/framework-bundle''symfony/validator'])) {
  1331.             $reflClass = new \ReflectionClass(Form::class);
  1332.             $fileRecorder('xml'\dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
  1333.         }
  1334.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1335.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1336.             if (
  1337.                 $container->fileExists($file $configDir.'/validation.yaml'false) ||
  1338.                 $container->fileExists($file $configDir.'/validation.yml'false)
  1339.             ) {
  1340.                 $fileRecorder('yml'$file);
  1341.             }
  1342.             if ($container->fileExists($file $configDir.'/validation.xml'false)) {
  1343.                 $fileRecorder('xml'$file);
  1344.             }
  1345.             if ($container->fileExists($dir $configDir.'/validation''/^$/')) {
  1346.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1347.             }
  1348.         }
  1349.         $projectDir $container->getParameter('kernel.project_dir');
  1350.         if ($container->fileExists($dir $projectDir.'/config/validator''/^$/')) {
  1351.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1352.         }
  1353.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1354.     }
  1355.     private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
  1356.     {
  1357.         foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
  1358.             $fileRecorder($file->getExtension(), $file->getRealPath());
  1359.         }
  1360.     }
  1361.     private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder)
  1362.     {
  1363.         foreach ($config['mapping']['paths'] as $path) {
  1364.             if (is_dir($path)) {
  1365.                 $this->registerMappingFilesFromDir($path$fileRecorder);
  1366.                 $container->addResource(new DirectoryResource($path'/^$/'));
  1367.             } elseif ($container->fileExists($pathfalse)) {
  1368.                 if (!preg_match('/\.(xml|ya?ml)$/'$path$matches)) {
  1369.                     throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.'$path));
  1370.                 }
  1371.                 $fileRecorder($matches[1], $path);
  1372.             } else {
  1373.                 throw new \RuntimeException(sprintf('Could not open file or directory "%s".'$path));
  1374.             }
  1375.         }
  1376.     }
  1377.     private function registerAnnotationsConfiguration(array $configContainerBuilder $containerLoaderInterface $loader)
  1378.     {
  1379.         if (!$this->isInitializedConfigEnabled('annotations')) {
  1380.             return;
  1381.         }
  1382.         if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
  1383.             throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed. Try running "composer require doctrine/annotations".');
  1384.         }
  1385.         $loader->load('annotations.php');
  1386.         // registerUniqueLoader exists since doctrine/annotations v1.6
  1387.         if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  1388.             // registerLoader exists only in doctrine/annotations v1
  1389.             if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
  1390.                 $container->getDefinition('annotations.dummy_registry')
  1391.                     ->setMethodCalls([['registerLoader', ['class_exists']]]);
  1392.             } else {
  1393.                 // remove the dummy registry when doctrine/annotations v2 is used
  1394.                 $container->removeDefinition('annotations.dummy_registry');
  1395.             }
  1396.         }
  1397.         if ('none' === $config['cache']) {
  1398.             $container->removeDefinition('annotations.cached_reader');
  1399.             return;
  1400.         }
  1401.         if ('php_array' === $config['cache']) {
  1402.             $cacheService 'annotations.cache_adapter';
  1403.             // Enable warmer only if PHP array is used for cache
  1404.             $definition $container->findDefinition('annotations.cache_warmer');
  1405.             $definition->addTag('kernel.cache_warmer');
  1406.         } else {
  1407.             $cacheService 'annotations.filesystem_cache_adapter';
  1408.             $cacheDir $container->getParameterBag()->resolveValue($config['file_cache_dir']);
  1409.             if (!is_dir($cacheDir) && false === @mkdir($cacheDir0777true) && !is_dir($cacheDir)) {
  1410.                 throw new \RuntimeException(sprintf('Could not create cache directory "%s".'$cacheDir));
  1411.             }
  1412.             $container
  1413.                 ->getDefinition('annotations.filesystem_cache_adapter')
  1414.                 ->replaceArgument(2$cacheDir)
  1415.             ;
  1416.         }
  1417.         $container
  1418.             ->getDefinition('annotations.cached_reader')
  1419.             ->replaceArgument(2$config['debug'])
  1420.             // reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
  1421.             ->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
  1422.         ;
  1423.         $container->setAlias('annotation_reader''annotations.cached_reader');
  1424.         $container->setAlias(Reader::class, new Alias('annotations.cached_reader'false));
  1425.         $container->removeDefinition('annotations.psr_cached_reader');
  1426.     }
  1427.     private function registerPropertyAccessConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1428.     {
  1429.         if (!$this->readConfigEnabled('property_access'$container$config)) {
  1430.             return;
  1431.         }
  1432.         $loader->load('property_access.php');
  1433.         $magicMethods PropertyAccessor::DISALLOW_MAGIC_METHODS;
  1434.         $magicMethods |= $config['magic_call'] ? PropertyAccessor::MAGIC_CALL 0;
  1435.         $magicMethods |= $config['magic_get'] ? PropertyAccessor::MAGIC_GET 0;
  1436.         $magicMethods |= $config['magic_set'] ? PropertyAccessor::MAGIC_SET 0;
  1437.         $throw PropertyAccessor::DO_NOT_THROW;
  1438.         $throw |= $config['throw_exception_on_invalid_index'] ? PropertyAccessor::THROW_ON_INVALID_INDEX 0;
  1439.         $throw |= $config['throw_exception_on_invalid_property_path'] ? PropertyAccessor::THROW_ON_INVALID_PROPERTY_PATH 0;
  1440.         $container
  1441.             ->getDefinition('property_accessor')
  1442.             ->replaceArgument(0$magicMethods)
  1443.             ->replaceArgument(1$throw)
  1444.             ->replaceArgument(3, new Reference(PropertyReadInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1445.             ->replaceArgument(4, new Reference(PropertyWriteInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1446.         ;
  1447.     }
  1448.     private function registerSecretsConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1449.     {
  1450.         if (!$this->readConfigEnabled('secrets'$container$config)) {
  1451.             $container->removeDefinition('console.command.secrets_set');
  1452.             $container->removeDefinition('console.command.secrets_list');
  1453.             $container->removeDefinition('console.command.secrets_remove');
  1454.             $container->removeDefinition('console.command.secrets_generate_key');
  1455.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1456.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1457.             return;
  1458.         }
  1459.         $loader->load('secrets.php');
  1460.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1461.         if ($config['local_dotenv_file']) {
  1462.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1463.         } else {
  1464.             $container->removeDefinition('secrets.local_vault');
  1465.         }
  1466.         if ($config['decryption_env_var']) {
  1467.             if (!preg_match('/^(?:[-.\w\\\\]*+:)*+\w++$/'$config['decryption_env_var'])) {
  1468.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1469.             }
  1470.             if (ContainerBuilder::willBeAvailable('symfony/string'LazyString::class, ['symfony/framework-bundle'])) {
  1471.                 $container->getDefinition('secrets.decryption_key')->replaceArgument(1$config['decryption_env_var']);
  1472.             } else {
  1473.                 $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1474.                 $container->removeDefinition('secrets.decryption_key');
  1475.             }
  1476.         } else {
  1477.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1478.             $container->removeDefinition('secrets.decryption_key');
  1479.         }
  1480.     }
  1481.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1482.     {
  1483.         if (!$this->readConfigEnabled('csrf_protection'$container$config)) {
  1484.             return;
  1485.         }
  1486.         if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
  1487.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1488.         }
  1489.         if (!$this->isInitializedConfigEnabled('session')) {
  1490.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1491.         }
  1492.         // Enable services for CSRF protection (even without forms)
  1493.         $loader->load('security_csrf.php');
  1494.         if (!class_exists(CsrfExtension::class)) {
  1495.             $container->removeDefinition('twig.extension.security_csrf');
  1496.         }
  1497.     }
  1498.     private function registerSerializerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1499.     {
  1500.         $loader->load('serializer.php');
  1501.         if ($container->getParameter('kernel.debug')) {
  1502.             $container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
  1503.         }
  1504.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1505.         if (!$this->isInitializedConfigEnabled('property_access')) {
  1506.             $container->removeAlias('serializer.property_accessor');
  1507.             $container->removeDefinition('serializer.normalizer.object');
  1508.         }
  1509.         if (!class_exists(Yaml::class)) {
  1510.             $container->removeDefinition('serializer.encoder.yaml');
  1511.         }
  1512.         if (!class_exists(UnwrappingDenormalizer::class) || !$this->isInitializedConfigEnabled('property_access')) {
  1513.             $container->removeDefinition('serializer.denormalizer.unwrapping');
  1514.         }
  1515.         if (!class_exists(Headers::class)) {
  1516.             $container->removeDefinition('serializer.normalizer.mime_message');
  1517.         }
  1518.         $serializerLoaders = [];
  1519.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1520.             $annotationLoader = new Definition(
  1521.                 AnnotationLoader::class,
  1522.                 [new Reference('annotation_reader'ContainerInterface::NULL_ON_INVALID_REFERENCE)]
  1523.             );
  1524.             $annotationLoader->setPublic(false);
  1525.             $serializerLoaders[] = $annotationLoader;
  1526.         }
  1527.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1528.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? YamlFileLoader::class : XmlFileLoader::class, [$path]);
  1529.             $definition->setPublic(false);
  1530.             $serializerLoaders[] = $definition;
  1531.         };
  1532.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1533.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1534.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1535.                 $fileRecorder('xml'$file);
  1536.             }
  1537.             if (
  1538.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1539.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1540.             ) {
  1541.                 $fileRecorder('yml'$file);
  1542.             }
  1543.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1544.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1545.             }
  1546.         }
  1547.         $projectDir $container->getParameter('kernel.project_dir');
  1548.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1549.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1550.         }
  1551.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1552.         $chainLoader->replaceArgument(0$serializerLoaders);
  1553.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1554.         if (isset($config['name_converter']) && $config['name_converter']) {
  1555.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1556.         }
  1557.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1558.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1559.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1560.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1561.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1562.         }
  1563.         if ($config['max_depth_handler'] ?? false) {
  1564.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1565.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1566.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1567.         }
  1568.         if (isset($config['default_context']) && $config['default_context']) {
  1569.             $container->setParameter('serializer.default_context'$config['default_context']);
  1570.         }
  1571.     }
  1572.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerPhpFileLoader $loader)
  1573.     {
  1574.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1575.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1576.         }
  1577.         $loader->load('property_info.php');
  1578.         if (
  1579.             ContainerBuilder::willBeAvailable('phpstan/phpdoc-parser'PhpDocParser::class, ['symfony/framework-bundle''symfony/property-info'])
  1580.             && ContainerBuilder::willBeAvailable('phpdocumentor/type-resolver'ContextFactory::class, ['symfony/framework-bundle''symfony/property-info'])
  1581.         ) {
  1582.             $definition $container->register('property_info.phpstan_extractor'PhpStanExtractor::class);
  1583.             $definition->addTag('property_info.type_extractor', ['priority' => -1000]);
  1584.         }
  1585.         if (ContainerBuilder::willBeAvailable('phpdocumentor/reflection-docblock'DocBlockFactoryInterface::class, ['symfony/framework-bundle''symfony/property-info'], true)) {
  1586.             $definition $container->register('property_info.php_doc_extractor'PhpDocExtractor::class);
  1587.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1588.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1589.         }
  1590.         if ($container->getParameter('kernel.debug')) {
  1591.             $container->removeDefinition('property_info.cache');
  1592.         }
  1593.     }
  1594.     private function registerLockConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1595.     {
  1596.         $loader->load('lock.php');
  1597.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1598.             if (=== \count($resourceStores)) {
  1599.                 continue;
  1600.             }
  1601.             // Generate stores
  1602.             $storeDefinitions = [];
  1603.             foreach ($resourceStores as $resourceStore) {
  1604.                 $storeDsn $container->resolveEnvPlaceholders($resourceStorenull$usedEnvs);
  1605.                 $storeDefinition = new Definition(PersistingStoreInterface::class);
  1606.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1607.                 $storeDefinition->setArguments([$resourceStore]);
  1608.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1609.                 $storeDefinition = new Reference($storeDefinitionId);
  1610.                 $storeDefinitions[] = $storeDefinition;
  1611.             }
  1612.             // Wrap array of stores with CombinedStore
  1613.             if (\count($storeDefinitions) > 1) {
  1614.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1615.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1616.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($resourceStores), $combinedDefinition);
  1617.             }
  1618.             // Generate factories for each resource
  1619.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1620.             $factoryDefinition->replaceArgument(0, new Reference($storeDefinitionId));
  1621.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1622.             // provide alias for default resource
  1623.             if ('default' === $resourceName) {
  1624.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1625.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1626.             } else {
  1627.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1628.             }
  1629.         }
  1630.     }
  1631.     private function registerSemaphoreConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1632.     {
  1633.         $loader->load('semaphore.php');
  1634.         foreach ($config['resources'] as $resourceName => $resourceStore) {
  1635.             $storeDsn $container->resolveEnvPlaceholders($resourceStorenull$usedEnvs);
  1636.             $storeDefinition = new Definition(SemaphoreStoreInterface::class);
  1637.             $storeDefinition->setFactory([SemaphoreStoreFactory::class, 'createStore']);
  1638.             $storeDefinition->setArguments([$resourceStore]);
  1639.             $container->setDefinition($storeDefinitionId '.semaphore.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1640.             // Generate factories for each resource
  1641.             $factoryDefinition = new ChildDefinition('semaphore.factory.abstract');
  1642.             $factoryDefinition->replaceArgument(0, new Reference($storeDefinitionId));
  1643.             $container->setDefinition('semaphore.'.$resourceName.'.factory'$factoryDefinition);
  1644.             // Generate services for semaphore instances
  1645.             $semaphoreDefinition = new Definition(Semaphore::class);
  1646.             $semaphoreDefinition->setPublic(false);
  1647.             $semaphoreDefinition->setFactory([new Reference('semaphore.'.$resourceName.'.factory'), 'createSemaphore']);
  1648.             $semaphoreDefinition->setArguments([$resourceName]);
  1649.             // provide alias for default resource
  1650.             if ('default' === $resourceName) {
  1651.                 $container->setAlias('semaphore.factory', new Alias('semaphore.'.$resourceName.'.factory'false));
  1652.                 $container->setAlias(SemaphoreFactory::class, new Alias('semaphore.factory'false));
  1653.             } else {
  1654.                 $container->registerAliasForArgument('semaphore.'.$resourceName.'.factory'SemaphoreFactory::class, $resourceName.'.semaphore.factory');
  1655.             }
  1656.         }
  1657.     }
  1658.     private function registerMessengerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader, array $validationConfig)
  1659.     {
  1660.         if (!interface_exists(MessageBusInterface::class)) {
  1661.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1662.         }
  1663.         if (!$this->hasConsole() || !class_exists(StatsCommand::class)) {
  1664.             $container->removeDefinition('console.command.messenger_stats');
  1665.         }
  1666.         $loader->load('messenger.php');
  1667.         if (!interface_exists(DenormalizerInterface::class)) {
  1668.             $container->removeDefinition('serializer.normalizer.flatten_exception');
  1669.         }
  1670.         if (ContainerBuilder::willBeAvailable('symfony/amqp-messenger'AmqpTransportFactory::class, ['symfony/framework-bundle''symfony/messenger'])) {
  1671.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1672.         }
  1673.         if (ContainerBuilder::willBeAvailable('symfony/redis-messenger'RedisTransportFactory::class, ['symfony/framework-bundle''symfony/messenger'])) {
  1674.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1675.         }
  1676.         if (ContainerBuilder::willBeAvailable('symfony/amazon-sqs-messenger'AmazonSqsTransportFactory::class, ['symfony/framework-bundle''symfony/messenger'])) {
  1677.             $container->getDefinition('messenger.transport.sqs.factory')->addTag('messenger.transport_factory');
  1678.         }
  1679.         if (ContainerBuilder::willBeAvailable('symfony/beanstalkd-messenger'BeanstalkdTransportFactory::class, ['symfony/framework-bundle''symfony/messenger'])) {
  1680.             $container->getDefinition('messenger.transport.beanstalkd.factory')->addTag('messenger.transport_factory');
  1681.         }
  1682.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1683.             $config['default_bus'] = key($config['buses']);
  1684.         }
  1685.         $defaultMiddleware = [
  1686.             'before' => [
  1687.                 ['id' => 'add_bus_name_stamp_middleware'],
  1688.                 ['id' => 'reject_redelivered_message_middleware'],
  1689.                 ['id' => 'dispatch_after_current_bus'],
  1690.                 ['id' => 'failed_message_processing_middleware'],
  1691.             ],
  1692.             'after' => [
  1693.                 ['id' => 'send_message'],
  1694.                 ['id' => 'handle_message'],
  1695.             ],
  1696.         ];
  1697.         foreach ($config['buses'] as $busId => $bus) {
  1698.             $middleware $bus['middleware'];
  1699.             if ($bus['default_middleware']['enabled']) {
  1700.                 $defaultMiddleware['after'][0]['arguments'] = [$bus['default_middleware']['allow_no_senders']];
  1701.                 $defaultMiddleware['after'][1]['arguments'] = [$bus['default_middleware']['allow_no_handlers']];
  1702.                 // argument to add_bus_name_stamp_middleware
  1703.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1704.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1705.             }
  1706.             foreach ($middleware as $middlewareItem) {
  1707.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1708.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1709.                 }
  1710.             }
  1711.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1712.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1713.             }
  1714.             $container->setParameter($busId.'.middleware'$middleware);
  1715.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1716.             if ($busId === $config['default_bus']) {
  1717.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1718.                 $container->setAlias(MessageBusInterface::class, $busId);
  1719.             } else {
  1720.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1721.             }
  1722.         }
  1723.         if (empty($config['transports'])) {
  1724.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1725.             $container->removeDefinition('messenger.transport.amqp.factory');
  1726.             $container->removeDefinition('messenger.transport.redis.factory');
  1727.             $container->removeDefinition('messenger.transport.sqs.factory');
  1728.             $container->removeDefinition('messenger.transport.beanstalkd.factory');
  1729.             $container->removeAlias(SerializerInterface::class);
  1730.         } else {
  1731.             $container->getDefinition('messenger.transport.symfony_serializer')
  1732.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1733.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1734.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1735.         }
  1736.         $failureTransports = [];
  1737.         if ($config['failure_transport']) {
  1738.             if (!isset($config['transports'][$config['failure_transport']])) {
  1739.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1740.             }
  1741.             $container->setAlias('messenger.failure_transports.default''messenger.transport.'.$config['failure_transport']);
  1742.             $failureTransports[] = $config['failure_transport'];
  1743.         }
  1744.         $failureTransportsByName = [];
  1745.         foreach ($config['transports'] as $name => $transport) {
  1746.             if ($transport['failure_transport']) {
  1747.                 $failureTransports[] = $transport['failure_transport'];
  1748.                 $failureTransportsByName[$name] = $transport['failure_transport'];
  1749.             } elseif ($config['failure_transport']) {
  1750.                 $failureTransportsByName[$name] = $config['failure_transport'];
  1751.             }
  1752.         }
  1753.         $senderAliases = [];
  1754.         $transportRetryReferences = [];
  1755.         $transportRateLimiterReferences = [];
  1756.         foreach ($config['transports'] as $name => $transport) {
  1757.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1758.             $transportDefinition = (new Definition(TransportInterface::class))
  1759.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1760.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1761.                 ->addTag('messenger.receiver', [
  1762.                         'alias' => $name,
  1763.                         'is_failure_transport' => \in_array($name$failureTransports),
  1764.                     ]
  1765.                 )
  1766.             ;
  1767.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1768.             $senderAliases[$name] = $transportId;
  1769.             if (null !== $transport['retry_strategy']['service']) {
  1770.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1771.             } else {
  1772.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1773.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1774.                 $retryDefinition
  1775.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1776.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1777.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1778.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1779.                 $container->setDefinition($retryServiceId$retryDefinition);
  1780.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1781.             }
  1782.             if ($transport['rate_limiter']) {
  1783.                 if (!interface_exists(LimiterInterface::class)) {
  1784.                     throw new LogicException('Rate limiter cannot be used within Messenger as the RateLimiter component is not installed. Try running "composer require symfony/rate-limiter".');
  1785.                 }
  1786.                 $transportRateLimiterReferences[$name] = new Reference('limiter.'.$transport['rate_limiter']);
  1787.             }
  1788.         }
  1789.         $senderReferences = [];
  1790.         // alias => service_id
  1791.         foreach ($senderAliases as $alias => $serviceId) {
  1792.             $senderReferences[$alias] = new Reference($serviceId);
  1793.         }
  1794.         // service_id => service_id
  1795.         foreach ($senderAliases as $serviceId) {
  1796.             $senderReferences[$serviceId] = new Reference($serviceId);
  1797.         }
  1798.         foreach ($config['transports'] as $name => $transport) {
  1799.             if ($transport['failure_transport']) {
  1800.                 if (!isset($senderReferences[$transport['failure_transport']])) {
  1801.                     throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$transport['failure_transport']));
  1802.                 }
  1803.             }
  1804.         }
  1805.         $failureTransportReferencesByTransportName array_map(function ($failureTransportName) use ($senderReferences) {
  1806.             return $senderReferences[$failureTransportName];
  1807.         }, $failureTransportsByName);
  1808.         $messageToSendersMapping = [];
  1809.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1810.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1811.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1812.             }
  1813.             // make sure senderAliases contains all senders
  1814.             foreach ($messageConfiguration['senders'] as $sender) {
  1815.                 if (!isset($senderReferences[$sender])) {
  1816.                     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));
  1817.                 }
  1818.             }
  1819.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1820.         }
  1821.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1822.         $container->getDefinition('messenger.senders_locator')
  1823.             ->replaceArgument(0$messageToSendersMapping)
  1824.             ->replaceArgument(1$sendersServiceLocator)
  1825.         ;
  1826.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1827.             ->replaceArgument(0$sendersServiceLocator)
  1828.         ;
  1829.         $container->getDefinition('messenger.retry_strategy_locator')
  1830.             ->replaceArgument(0$transportRetryReferences);
  1831.         if (!$transportRateLimiterReferences) {
  1832.             $container->removeDefinition('messenger.rate_limiter_locator');
  1833.         } else {
  1834.             $container->getDefinition('messenger.rate_limiter_locator')
  1835.                 ->replaceArgument(0$transportRateLimiterReferences);
  1836.         }
  1837.         if (\count($failureTransports) > 0) {
  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.             $failureTransportsByTransportNameServiceLocator ServiceLocatorTagPass::register($container$failureTransportReferencesByTransportName);
  1845.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1846.                 ->replaceArgument(0$failureTransportsByTransportNameServiceLocator);
  1847.         } else {
  1848.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1849.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1850.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1851.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1852.         }
  1853.         if (!$container->hasDefinition('console.command.messenger_consume_messages')) {
  1854.             $container->removeDefinition('messenger.listener.reset_services');
  1855.         }
  1856.     }
  1857.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1858.     {
  1859.         if (!class_exists(DefaultMarshaller::class)) {
  1860.             $container->removeDefinition('cache.default_marshaller');
  1861.         }
  1862.         $version = new Parameter('container.build_id');
  1863.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1864.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1865.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1866.         if (isset($config['prefix_seed'])) {
  1867.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1868.         }
  1869.         if ($container->hasParameter('cache.prefix.seed')) {
  1870.             // Inline any env vars referenced in the parameter
  1871.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1872.         }
  1873.         foreach (['psr6''redis''memcached''doctrine_dbal''pdo'] as $name) {
  1874.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1875.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1876.             }
  1877.         }
  1878.         foreach (['app''system'] as $name) {
  1879.             $config['pools']['cache.'.$name] = [
  1880.                 'adapters' => [$config[$name]],
  1881.                 'public' => true,
  1882.                 'tags' => false,
  1883.             ];
  1884.         }
  1885.         foreach ($config['pools'] as $name => $pool) {
  1886.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1887.             $isRedisTagAware = ['cache.adapter.redis_tag_aware'] === $pool['adapters'];
  1888.             foreach ($pool['adapters'] as $provider => $adapter) {
  1889.                 if (($config['pools'][$adapter]['adapters'] ?? null) === ['cache.adapter.redis_tag_aware']) {
  1890.                     $isRedisTagAware true;
  1891.                 } elseif ($config['pools'][$adapter]['tags'] ?? false) {
  1892.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1893.                 }
  1894.             }
  1895.             if (=== \count($pool['adapters'])) {
  1896.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1897.                     $pool['provider'] = $provider;
  1898.                 }
  1899.                 $definition = new ChildDefinition($adapter);
  1900.             } else {
  1901.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1902.                 $pool['reset'] = 'reset';
  1903.             }
  1904.             if ($isRedisTagAware && 'cache.app' === $name) {
  1905.                 $container->setAlias('cache.app.taggable'$name);
  1906.                 $definition->addTag('cache.taggable', ['pool' => $name]);
  1907.             } elseif ($isRedisTagAware) {
  1908.                 $tagAwareId $name;
  1909.                 $container->setAlias('.'.$name.'.inner'$name);
  1910.                 $definition->addTag('cache.taggable', ['pool' => $name]);
  1911.             } elseif ($pool['tags']) {
  1912.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1913.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1914.                 }
  1915.                 $container->register($nameTagAwareAdapter::class)
  1916.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1917.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1918.                     ->setPublic($pool['public'])
  1919.                     ->addTag('cache.taggable', ['pool' => $name])
  1920.                 ;
  1921.                 if (method_exists(TagAwareAdapter::class, 'setLogger')) {
  1922.                     $container
  1923.                         ->getDefinition($name)
  1924.                         ->addMethodCall('setLogger', [new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])
  1925.                         ->addTag('monolog.logger', ['channel' => 'cache']);
  1926.                 }
  1927.                 $pool['name'] = $tagAwareId $name;
  1928.                 $pool['public'] = false;
  1929.                 $name '.'.$name.'.inner';
  1930.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1931.                 $tagAwareId '.'.$name.'.taggable';
  1932.                 $container->register($tagAwareIdTagAwareAdapter::class)
  1933.                     ->addArgument(new Reference($name))
  1934.                     ->addTag('cache.taggable', ['pool' => $name])
  1935.                 ;
  1936.             }
  1937.             if (!\in_array($name, ['cache.app''cache.system'], true)) {
  1938.                 $container->registerAliasForArgument($tagAwareIdTagAwareCacheInterface::class, $pool['name'] ?? $name);
  1939.                 $container->registerAliasForArgument($nameCacheInterface::class, $pool['name'] ?? $name);
  1940.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name'] ?? $name);
  1941.             }
  1942.             $definition->setPublic($pool['public']);
  1943.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1944.             $definition->addTag('cache.pool'$pool);
  1945.             $container->setDefinition($name$definition);
  1946.         }
  1947.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1948.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1949.             $propertyAccessDefinition->setPublic(false);
  1950.             if (!$container->getParameter('kernel.debug')) {
  1951.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1952.                 $propertyAccessDefinition->setArguments([''0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1953.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1954.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1955.             } else {
  1956.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1957.                 $propertyAccessDefinition->setArguments([0false]);
  1958.             }
  1959.         }
  1960.     }
  1961.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  1962.     {
  1963.         $loader->load('http_client.php');
  1964.         $options $config['default_options'] ?? [];
  1965.         $retryOptions $options['retry_failed'] ?? ['enabled' => false];
  1966.         unset($options['retry_failed']);
  1967.         $container->getDefinition('http_client')->setArguments([$options$config['max_host_connections'] ?? 6]);
  1968.         if (!$hasPsr18 ContainerBuilder::willBeAvailable('psr/http-client'ClientInterface::class, ['symfony/framework-bundle''symfony/http-client'])) {
  1969.             $container->removeDefinition('psr18.http_client');
  1970.             $container->removeAlias(ClientInterface::class);
  1971.         }
  1972.         if (!ContainerBuilder::willBeAvailable('php-http/httplug'HttpClient::class, ['symfony/framework-bundle''symfony/http-client'])) {
  1973.             $container->removeDefinition(HttpClient::class);
  1974.         }
  1975.         if ($this->readConfigEnabled('http_client.retry_failed'$container$retryOptions)) {
  1976.             $this->registerRetryableHttpClient($retryOptions'http_client'$container);
  1977.         }
  1978.         $httpClientId = ($retryOptions['enabled'] ?? false) ? 'http_client.retryable.inner' : ($this->isInitializedConfigEnabled('profiler') ? '.debug.http_client.inner' 'http_client');
  1979.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1980.             if ('http_client' === $name) {
  1981.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1982.             }
  1983.             $scope $scopeConfig['scope'] ?? null;
  1984.             unset($scopeConfig['scope']);
  1985.             $retryOptions $scopeConfig['retry_failed'] ?? ['enabled' => false];
  1986.             unset($scopeConfig['retry_failed']);
  1987.             if (null === $scope) {
  1988.                 $baseUri $scopeConfig['base_uri'];
  1989.                 unset($scopeConfig['base_uri']);
  1990.                 $container->register($nameScopingHttpClient::class)
  1991.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1992.                     ->setArguments([new Reference($httpClientId), $baseUri$scopeConfig])
  1993.                     ->addTag('http_client.client')
  1994.                 ;
  1995.             } else {
  1996.                 $container->register($nameScopingHttpClient::class)
  1997.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1998.                     ->addTag('http_client.client')
  1999.                 ;
  2000.             }
  2001.             if ($this->readConfigEnabled('http_client.scoped_clients.'.$name.'retry_failed'$container$retryOptions)) {
  2002.                 $this->registerRetryableHttpClient($retryOptions$name$container);
  2003.             }
  2004.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  2005.             if ($hasPsr18) {
  2006.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  2007.                     ->replaceArgument(0, new Reference($name));
  2008.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  2009.             }
  2010.         }
  2011.         if ($responseFactoryId $config['mock_response_factory'] ?? null) {
  2012.             $container->register($httpClientId.'.mock_client'MockHttpClient::class)
  2013.                 ->setDecoratedService($httpClientIdnull, -10// lower priority than TraceableHttpClient
  2014.                 ->setArguments([new Reference($responseFactoryId)]);
  2015.         }
  2016.     }
  2017.     private function registerRetryableHttpClient(array $optionsstring $nameContainerBuilder $container)
  2018.     {
  2019.         if (!class_exists(RetryableHttpClient::class)) {
  2020.             throw new LogicException('Support for retrying failed requests requires symfony/http-client 5.2 or higher, try upgrading.');
  2021.         }
  2022.         if (null !== $options['retry_strategy']) {
  2023.             $retryStrategy = new Reference($options['retry_strategy']);
  2024.         } else {
  2025.             $retryStrategy = new ChildDefinition('http_client.abstract_retry_strategy');
  2026.             $codes = [];
  2027.             foreach ($options['http_codes'] as $code => $codeOptions) {
  2028.                 if ($codeOptions['methods']) {
  2029.                     $codes[$code] = $codeOptions['methods'];
  2030.                 } else {
  2031.                     $codes[] = $code;
  2032.                 }
  2033.             }
  2034.             $retryStrategy
  2035.                 ->replaceArgument(0$codes ?: GenericRetryStrategy::DEFAULT_RETRY_STATUS_CODES)
  2036.                 ->replaceArgument(1$options['delay'])
  2037.                 ->replaceArgument(2$options['multiplier'])
  2038.                 ->replaceArgument(3$options['max_delay'])
  2039.                 ->replaceArgument(4$options['jitter']);
  2040.             $container->setDefinition($name.'.retry_strategy'$retryStrategy);
  2041.             $retryStrategy = new Reference($name.'.retry_strategy');
  2042.         }
  2043.         $container
  2044.             ->register($name.'.retryable'RetryableHttpClient::class)
  2045.             ->setDecoratedService($namenull10// higher priority than TraceableHttpClient
  2046.             ->setArguments([new Reference($name.'.retryable.inner'), $retryStrategy$options['max_retries'], new Reference('logger')])
  2047.             ->addTag('monolog.logger', ['channel' => 'http_client']);
  2048.     }
  2049.     private function registerMailerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  2050.     {
  2051.         if (!class_exists(Mailer::class)) {
  2052.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  2053.         }
  2054.         $loader->load('mailer.php');
  2055.         $loader->load('mailer_transports.php');
  2056.         if (!\count($config['transports']) && null === $config['dsn']) {
  2057.             $config['dsn'] = 'smtp://null';
  2058.         }
  2059.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  2060.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  2061.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  2062.         $mailer $container->getDefinition('mailer.mailer');
  2063.         if (false === $messageBus $config['message_bus']) {
  2064.             $mailer->replaceArgument(1null);
  2065.         } else {
  2066.             $mailer->replaceArgument(1$messageBus ? new Reference($messageBus) : new Reference('messenger.default_bus'ContainerInterface::NULL_ON_INVALID_REFERENCE));
  2067.         }
  2068.         $classToServices = [
  2069.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  2070.             InfobipMailerTransportFactory::class => 'mailer.transport_factory.infobip',
  2071.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  2072.             MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
  2073.             MailPaceTransportFactory::class => 'mailer.transport_factory.mailpace',
  2074.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  2075.             OhMySmtpTransportFactory::class => 'mailer.transport_factory.ohmysmtp',
  2076.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  2077.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  2078.             SendinblueTransportFactory::class => 'mailer.transport_factory.sendinblue',
  2079.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  2080.         ];
  2081.         foreach ($classToServices as $class => $service) {
  2082.             $package substr($service\strlen('mailer.transport_factory.'));
  2083.             if (!ContainerBuilder::willBeAvailable(sprintf('symfony/%s-mailer''gmail' === $package 'google' $package), $class, ['symfony/framework-bundle''symfony/mailer'])) {
  2084.                 $container->removeDefinition($service);
  2085.             }
  2086.         }
  2087.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  2088.         $envelopeListener->setArgument(0$config['envelope']['sender'] ?? null);
  2089.         $envelopeListener->setArgument(1$config['envelope']['recipients'] ?? null);
  2090.         if ($config['headers']) {
  2091.             $headers = new Definition(Headers::class);
  2092.             foreach ($config['headers'] as $name => $data) {
  2093.                 $value $data['value'];
  2094.                 if (\in_array(strtolower($name), ['from''to''cc''bcc''reply-to'])) {
  2095.                     $value = (array) $value;
  2096.                 }
  2097.                 $headers->addMethodCall('addHeader', [$name$value]);
  2098.             }
  2099.             $messageListener $container->getDefinition('mailer.message_listener');
  2100.             $messageListener->setArgument(0$headers);
  2101.         } else {
  2102.             $container->removeDefinition('mailer.message_listener');
  2103.         }
  2104.         if (!class_exists(MessengerTransportListener::class)) {
  2105.             $container->removeDefinition('mailer.messenger_transport_listener');
  2106.         }
  2107.     }
  2108.     private function registerNotifierConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  2109.     {
  2110.         if (!class_exists(Notifier::class)) {
  2111.             throw new LogicException('Notifier support cannot be enabled as the component is not installed. Try running "composer require symfony/notifier".');
  2112.         }
  2113.         $loader->load('notifier.php');
  2114.         $loader->load('notifier_transports.php');
  2115.         if ($config['chatter_transports']) {
  2116.             $container->getDefinition('chatter.transports')->setArgument(0$config['chatter_transports']);
  2117.         } else {
  2118.             $container->removeDefinition('chatter');
  2119.             $container->removeAlias(ChatterInterface::class);
  2120.         }
  2121.         if ($config['texter_transports']) {
  2122.             $container->getDefinition('texter.transports')->setArgument(0$config['texter_transports']);
  2123.         } else {
  2124.             $container->removeDefinition('texter');
  2125.             $container->removeAlias(TexterInterface::class);
  2126.         }
  2127.         if ($this->isInitializedConfigEnabled('mailer')) {
  2128.             $sender $container->getDefinition('mailer.envelope_listener')->getArgument(0);
  2129.             $container->getDefinition('notifier.channel.email')->setArgument(2$sender);
  2130.         } else {
  2131.             $container->removeDefinition('notifier.channel.email');
  2132.         }
  2133.         if ($this->isInitializedConfigEnabled('messenger')) {
  2134.             if ($config['notification_on_failed_messages']) {
  2135.                 $container->getDefinition('notifier.failed_message_listener')->addTag('kernel.event_subscriber');
  2136.             }
  2137.             // as we have a bus, the channels don't need the transports
  2138.             $container->getDefinition('notifier.channel.chat')->setArgument(0null);
  2139.             if ($container->hasDefinition('notifier.channel.email')) {
  2140.                 $container->getDefinition('notifier.channel.email')->setArgument(0null);
  2141.             }
  2142.             $container->getDefinition('notifier.channel.sms')->setArgument(0null);
  2143.             $container->getDefinition('notifier.channel.push')->setArgument(0null);
  2144.         }
  2145.         $container->getDefinition('notifier.channel_policy')->setArgument(0$config['channel_policy']);
  2146.         $container->registerForAutoconfiguration(NotifierTransportFactoryInterface::class)
  2147.             ->addTag('chatter.transport_factory');
  2148.         $container->registerForAutoconfiguration(NotifierTransportFactoryInterface::class)
  2149.             ->addTag('texter.transport_factory');
  2150.         $classToServices = [
  2151.             AllMySmsTransportFactory::class => 'notifier.transport_factory.all-my-sms',
  2152.             AmazonSnsTransportFactory::class => 'notifier.transport_factory.amazon-sns',
  2153.             ChatworkTransportFactory::class => 'notifier.transport_factory.chatwork',
  2154.             ClickatellTransportFactory::class => 'notifier.transport_factory.clickatell',
  2155.             ContactEveryoneTransportFactory::class => 'notifier.transport_factory.contact-everyone',
  2156.             DiscordTransportFactory::class => 'notifier.transport_factory.discord',
  2157.             EngagespotTransportFactory::class => 'notifier.transport_factory.engagespot',
  2158.             EsendexTransportFactory::class => 'notifier.transport_factory.esendex',
  2159.             ExpoTransportFactory::class => 'notifier.transport_factory.expo',
  2160.             FakeChatTransportFactory::class => 'notifier.transport_factory.fake-chat',
  2161.             FakeSmsTransportFactory::class => 'notifier.transport_factory.fake-sms',
  2162.             FirebaseTransportFactory::class => 'notifier.transport_factory.firebase',
  2163.             FortySixElksTransportFactory::class => 'notifier.transport_factory.forty-six-elks',
  2164.             FreeMobileTransportFactory::class => 'notifier.transport_factory.free-mobile',
  2165.             GatewayApiTransportFactory::class => 'notifier.transport_factory.gateway-api',
  2166.             GitterTransportFactory::class => 'notifier.transport_factory.gitter',
  2167.             GoogleChatTransportFactory::class => 'notifier.transport_factory.google-chat',
  2168.             InfobipTransportFactory::class => 'notifier.transport_factory.infobip',
  2169.             IqsmsTransportFactory::class => 'notifier.transport_factory.iqsms',
  2170.             KazInfoTehTransportFactory::class => 'notifier.transport_factory.kaz-info-teh',
  2171.             LightSmsTransportFactory::class => 'notifier.transport_factory.light-sms',
  2172.             LinkedInTransportFactory::class => 'notifier.transport_factory.linked-in',
  2173.             MailjetNotifierTransportFactory::class => 'notifier.transport_factory.mailjet',
  2174.             MattermostTransportFactory::class => 'notifier.transport_factory.mattermost',
  2175.             MercureTransportFactory::class => 'notifier.transport_factory.mercure',
  2176.             MessageBirdTransport::class => 'notifier.transport_factory.message-bird',
  2177.             MessageMediaTransportFactory::class => 'notifier.transport_factory.message-media',
  2178.             MicrosoftTeamsTransportFactory::class => 'notifier.transport_factory.microsoft-teams',
  2179.             MobytTransportFactory::class => 'notifier.transport_factory.mobyt',
  2180.             OctopushTransportFactory::class => 'notifier.transport_factory.octopush',
  2181.             OneSignalTransportFactory::class => 'notifier.transport_factory.one-signal',
  2182.             OrangeSmsTransportFactory::class => 'notifier.transport_factory.orange-sms',
  2183.             OvhCloudTransportFactory::class => 'notifier.transport_factory.ovh-cloud',
  2184.             RocketChatTransportFactory::class => 'notifier.transport_factory.rocket-chat',
  2185.             SendberryTransportFactory::class => 'notifier.transport_factory.sendberry',
  2186.             SendinblueNotifierTransportFactory::class => 'notifier.transport_factory.sendinblue',
  2187.             SinchTransportFactory::class => 'notifier.transport_factory.sinch',
  2188.             SlackTransportFactory::class => 'notifier.transport_factory.slack',
  2189.             Sms77TransportFactory::class => 'notifier.transport_factory.sms77',
  2190.             SmsapiTransportFactory::class => 'notifier.transport_factory.smsapi',
  2191.             SmsBiurasTransportFactory::class => 'notifier.transport_factory.sms-biuras',
  2192.             SmscTransportFactory::class => 'notifier.transport_factory.smsc',
  2193.             SmsFactorTransportFactory::class => 'notifier.transport_factory.sms-factor',
  2194.             SpotHitTransportFactory::class => 'notifier.transport_factory.spot-hit',
  2195.             TelegramTransportFactory::class => 'notifier.transport_factory.telegram',
  2196.             TelnyxTransportFactory::class => 'notifier.transport_factory.telnyx',
  2197.             TurboSmsTransport::class => 'notifier.transport_factory.turbo-sms',
  2198.             TwilioTransportFactory::class => 'notifier.transport_factory.twilio',
  2199.             VonageTransportFactory::class => 'notifier.transport_factory.vonage',
  2200.             YunpianTransportFactory::class => 'notifier.transport_factory.yunpian',
  2201.             ZendeskTransportFactory::class => 'notifier.transport_factory.zendesk',
  2202.             ZulipTransportFactory::class => 'notifier.transport_factory.zulip',
  2203.         ];
  2204.         $parentPackages = ['symfony/framework-bundle''symfony/notifier'];
  2205.         foreach ($classToServices as $class => $service) {
  2206.             $package substr($service\strlen('notifier.transport_factory.'));
  2207.             if (!ContainerBuilder::willBeAvailable(sprintf('symfony/%s-notifier'$package), $class$parentPackages)) {
  2208.                 $container->removeDefinition($service);
  2209.             }
  2210.         }
  2211.         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)) {
  2212.             $container->getDefinition($classToServices[MercureTransportFactory::class])
  2213.                 ->replaceArgument('$registry', new Reference(HubRegistry::class));
  2214.         } elseif (ContainerBuilder::willBeAvailable('symfony/mercure-notifier'MercureTransportFactory::class, $parentPackages)) {
  2215.             $container->removeDefinition($classToServices[MercureTransportFactory::class]);
  2216.         }
  2217.         if (ContainerBuilder::willBeAvailable('symfony/fake-chat-notifier'FakeChatTransportFactory::class, ['symfony/framework-bundle''symfony/notifier''symfony/mailer'])) {
  2218.             $container->getDefinition($classToServices[FakeChatTransportFactory::class])
  2219.                 ->replaceArgument('$mailer', new Reference('mailer'))
  2220.                 ->replaceArgument('$logger', new Reference('logger'));
  2221.         }
  2222.         if (ContainerBuilder::willBeAvailable('symfony/fake-sms-notifier'FakeSmsTransportFactory::class, ['symfony/framework-bundle''symfony/notifier''symfony/mailer'])) {
  2223.             $container->getDefinition($classToServices[FakeSmsTransportFactory::class])
  2224.                 ->replaceArgument('$mailer', new Reference('mailer'))
  2225.                 ->replaceArgument('$logger', new Reference('logger'));
  2226.         }
  2227.         if (isset($config['admin_recipients'])) {
  2228.             $notifier $container->getDefinition('notifier');
  2229.             foreach ($config['admin_recipients'] as $i => $recipient) {
  2230.                 $id 'notifier.admin_recipient.'.$i;
  2231.                 $container->setDefinition($id, new Definition(Recipient::class, [$recipient['email'], $recipient['phone']]));
  2232.                 $notifier->addMethodCall('addAdminRecipient', [new Reference($id)]);
  2233.             }
  2234.         }
  2235.     }
  2236.     private function registerRateLimiterConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  2237.     {
  2238.         $loader->load('rate_limiter.php');
  2239.         foreach ($config['limiters'] as $name => $limiterConfig) {
  2240.             // default configuration (when used by other DI extensions)
  2241.             $limiterConfig += ['lock_factory' => 'lock.factory''cache_pool' => 'cache.rate_limiter'];
  2242.             $limiter $container->setDefinition($limiterId 'limiter.'.$name, new ChildDefinition('limiter'));
  2243.             if (null !== $limiterConfig['lock_factory']) {
  2244.                 if (!interface_exists(LockInterface::class)) {
  2245.                     throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be installed. Try running "composer require symfony/lock".'$name));
  2246.                 }
  2247.                 if (!$this->isInitializedConfigEnabled('lock')) {
  2248.                     throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be configured.'$name));
  2249.                 }
  2250.                 $limiter->replaceArgument(2, new Reference($limiterConfig['lock_factory']));
  2251.             }
  2252.             unset($limiterConfig['lock_factory']);
  2253.             if (null === $storageId $limiterConfig['storage_service'] ?? null) {
  2254.                 $container->register($storageId 'limiter.storage.'.$nameCacheStorage::class)->addArgument(new Reference($limiterConfig['cache_pool']));
  2255.             }
  2256.             $limiter->replaceArgument(1, new Reference($storageId));
  2257.             unset($limiterConfig['storage_service'], $limiterConfig['cache_pool']);
  2258.             $limiterConfig['id'] = $name;
  2259.             $limiter->replaceArgument(0$limiterConfig);
  2260.             $container->registerAliasForArgument($limiterIdRateLimiterFactory::class, $name.'.limiter');
  2261.         }
  2262.     }
  2263.     /**
  2264.      * @deprecated since Symfony 6.2
  2265.      */
  2266.     public static function registerRateLimiter(ContainerBuilder $containerstring $name, array $limiterConfig)
  2267.     {
  2268.         trigger_deprecation('symfony/framework-bundle''6.2''The "%s()" method is deprecated.'__METHOD__);
  2269.         // default configuration (when used by other DI extensions)
  2270.         $limiterConfig += ['lock_factory' => 'lock.factory''cache_pool' => 'cache.rate_limiter'];
  2271.         $limiter $container->setDefinition($limiterId 'limiter.'.$name, new ChildDefinition('limiter'));
  2272.         if (null !== $limiterConfig['lock_factory']) {
  2273.             if (!interface_exists(LockInterface::class)) {
  2274.                 throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be installed. Try running "composer require symfony/lock".'$name));
  2275.             }
  2276.             if (!$container->hasDefinition('lock.factory.abstract')) {
  2277.                 throw new LogicException(sprintf('Rate limiter "%s" requires the Lock component to be configured.'$name));
  2278.             }
  2279.             $limiter->replaceArgument(2, new Reference($limiterConfig['lock_factory']));
  2280.         }
  2281.         unset($limiterConfig['lock_factory']);
  2282.         if (null === $storageId $limiterConfig['storage_service'] ?? null) {
  2283.             $container->register($storageId 'limiter.storage.'.$nameCacheStorage::class)->addArgument(new Reference($limiterConfig['cache_pool']));
  2284.         }
  2285.         $limiter->replaceArgument(1, new Reference($storageId));
  2286.         unset($limiterConfig['storage_service'], $limiterConfig['cache_pool']);
  2287.         $limiterConfig['id'] = $name;
  2288.         $limiter->replaceArgument(0$limiterConfig);
  2289.         $container->registerAliasForArgument($limiterIdRateLimiterFactory::class, $name.'.limiter');
  2290.     }
  2291.     private function registerUidConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  2292.     {
  2293.         $loader->load('uid.php');
  2294.         $container->getDefinition('uuid.factory')
  2295.             ->setArguments([
  2296.                 $config['default_uuid_version'],
  2297.                 $config['time_based_uuid_version'],
  2298.                 $config['name_based_uuid_version'],
  2299.                 UuidV4::class,
  2300.                 $config['time_based_uuid_node'] ?? null,
  2301.                 $config['name_based_uuid_namespace'] ?? null,
  2302.             ])
  2303.         ;
  2304.         if (isset($config['name_based_uuid_namespace'])) {
  2305.             $container->getDefinition('name_based_uuid.factory')
  2306.                 ->setArguments([$config['name_based_uuid_namespace']]);
  2307.         }
  2308.         if (!class_exists(UidValueResolver::class)) {
  2309.             $container->removeDefinition('argument_resolver.uid');
  2310.         }
  2311.     }
  2312.     private function registerHtmlSanitizerConfiguration(array $configContainerBuilder $containerPhpFileLoader $loader)
  2313.     {
  2314.         $loader->load('html_sanitizer.php');
  2315.         foreach ($config['sanitizers'] as $sanitizerName => $sanitizerConfig) {
  2316.             $configId 'html_sanitizer.config.'.$sanitizerName;
  2317.             $def $container->register($configIdHtmlSanitizerConfig::class);
  2318.             // Base
  2319.             if ($sanitizerConfig['allow_safe_elements']) {
  2320.                 $def->addMethodCall('allowSafeElements', [], true);
  2321.             }
  2322.             if ($sanitizerConfig['allow_static_elements']) {
  2323.                 $def->addMethodCall('allowStaticElements', [], true);
  2324.             }
  2325.             // Configures elements
  2326.             foreach ($sanitizerConfig['allow_elements'] as $element => $attributes) {
  2327.                 $def->addMethodCall('allowElement', [$element$attributes], true);
  2328.             }
  2329.             foreach ($sanitizerConfig['block_elements'] as $element) {
  2330.                 $def->addMethodCall('blockElement', [$element], true);
  2331.             }
  2332.             foreach ($sanitizerConfig['drop_elements'] as $element) {
  2333.                 $def->addMethodCall('dropElement', [$element], true);
  2334.             }
  2335.             // Configures attributes
  2336.             foreach ($sanitizerConfig['allow_attributes'] as $attribute => $elements) {
  2337.                 $def->addMethodCall('allowAttribute', [$attribute$elements], true);
  2338.             }
  2339.             foreach ($sanitizerConfig['drop_attributes'] as $attribute => $elements) {
  2340.                 $def->addMethodCall('dropAttribute', [$attribute$elements], true);
  2341.             }
  2342.             // Force attributes
  2343.             foreach ($sanitizerConfig['force_attributes'] as $element => $attributes) {
  2344.                 foreach ($attributes as $attrName => $attrValue) {
  2345.                     $def->addMethodCall('forceAttribute', [$element$attrName$attrValue], true);
  2346.                 }
  2347.             }
  2348.             // Settings
  2349.             $def->addMethodCall('forceHttpsUrls', [$sanitizerConfig['force_https_urls']], true);
  2350.             if ($sanitizerConfig['allowed_link_schemes']) {
  2351.                 $def->addMethodCall('allowLinkSchemes', [$sanitizerConfig['allowed_link_schemes']], true);
  2352.             }
  2353.             $def->addMethodCall('allowLinkHosts', [$sanitizerConfig['allowed_link_hosts']], true);
  2354.             $def->addMethodCall('allowRelativeLinks', [$sanitizerConfig['allow_relative_links']], true);
  2355.             if ($sanitizerConfig['allowed_media_schemes']) {
  2356.                 $def->addMethodCall('allowMediaSchemes', [$sanitizerConfig['allowed_media_schemes']], true);
  2357.             }
  2358.             $def->addMethodCall('allowMediaHosts', [$sanitizerConfig['allowed_media_hosts']], true);
  2359.             $def->addMethodCall('allowRelativeMedias', [$sanitizerConfig['allow_relative_medias']], true);
  2360.             // Custom attribute sanitizers
  2361.             foreach ($sanitizerConfig['with_attribute_sanitizers'] as $serviceName) {
  2362.                 $def->addMethodCall('withAttributeSanitizer', [new Reference($serviceName)], true);
  2363.             }
  2364.             foreach ($sanitizerConfig['without_attribute_sanitizers'] as $serviceName) {
  2365.                 $def->addMethodCall('withoutAttributeSanitizer', [new Reference($serviceName)], true);
  2366.             }
  2367.             if ($sanitizerConfig['max_input_length']) {
  2368.                 $def->addMethodCall('withMaxInputLength', [$sanitizerConfig['max_input_length']], true);
  2369.             }
  2370.             // Create the sanitizer and link its config
  2371.             $sanitizerId 'html_sanitizer.sanitizer.'.$sanitizerName;
  2372.             $container->register($sanitizerIdHtmlSanitizer::class)
  2373.                 ->addTag('html_sanitizer', ['sanitizer' => $sanitizerName])
  2374.                 ->addArgument(new Reference($configId));
  2375.             if ('default' !== $sanitizerName) {
  2376.                 $container->registerAliasForArgument($sanitizerIdHtmlSanitizerInterface::class, $sanitizerName);
  2377.             }
  2378.         }
  2379.     }
  2380.     private function resolveTrustedHeaders(array $headers): int
  2381.     {
  2382.         $trustedHeaders 0;
  2383.         foreach ($headers as $h) {
  2384.             $trustedHeaders |= match ($h) {
  2385.                 'forwarded' => Request::HEADER_FORWARDED,
  2386.                 'x-forwarded-for' => Request::HEADER_X_FORWARDED_FOR,
  2387.                 'x-forwarded-host' => Request::HEADER_X_FORWARDED_HOST,
  2388.                 'x-forwarded-proto' => Request::HEADER_X_FORWARDED_PROTO,
  2389.                 'x-forwarded-port' => Request::HEADER_X_FORWARDED_PORT,
  2390.                 'x-forwarded-prefix' => Request::HEADER_X_FORWARDED_PREFIX,
  2391.                 default => 0,
  2392.             };
  2393.         }
  2394.         return $trustedHeaders;
  2395.     }
  2396.     public function getXsdValidationBasePath(): string|false
  2397.     {
  2398.         return \dirname(__DIR__).'/Resources/config/schema';
  2399.     }
  2400.     public function getNamespace(): string
  2401.     {
  2402.         return 'http://symfony.com/schema/dic/symfony';
  2403.     }
  2404.     protected function isConfigEnabled(ContainerBuilder $container, array $config): bool
  2405.     {
  2406.         throw new \LogicException('To prevent using outdated configuration, you must use the "readConfigEnabled" method instead.');
  2407.     }
  2408.     private function isInitializedConfigEnabled(string $path): bool
  2409.     {
  2410.         if (isset($this->configsEnabled[$path])) {
  2411.             return $this->configsEnabled[$path];
  2412.         }
  2413.         throw new LogicException(sprintf('Can not read config enabled at "%s" because it has not been initialized.'$path));
  2414.     }
  2415.     private function readConfigEnabled(string $pathContainerBuilder $container, array $config): bool
  2416.     {
  2417.         return $this->configsEnabled[$path] ??= parent::isConfigEnabled($container$config);
  2418.     }
  2419.     private function writeConfigEnabled(string $pathbool $value, array &$config): void
  2420.     {
  2421.         if (isset($this->configsEnabled[$path])) {
  2422.             throw new LogicException('Can not change config enabled because it has already been read.');
  2423.         }
  2424.         $this->configsEnabled[$path] = $value;
  2425.         $config['enabled'] = $value;
  2426.     }
  2427. }