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

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
  11. use Doctrine\Common\Annotations\AnnotationRegistry;
  12. use Doctrine\Common\Annotations\Reader;
  13. use Http\Client\HttpClient;
  14. use Psr\Cache\CacheItemPoolInterface;
  15. use Psr\Container\ContainerInterface as PsrContainerInterface;
  16. use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;
  17. use Psr\Http\Client\ClientInterface;
  18. use Psr\Log\LoggerAwareInterface;
  19. use Symfony\Bridge\Monolog\Processor\DebugProcessor;
  20. use Symfony\Bridge\Twig\Extension\CsrfExtension;
  21. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  22. use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
  23. use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
  24. use Symfony\Bundle\FullStack;
  25. use Symfony\Component\Asset\PackageInterface;
  26. use Symfony\Component\BrowserKit\AbstractBrowser;
  27. use Symfony\Component\Cache\Adapter\AdapterInterface;
  28. use Symfony\Component\Cache\Adapter\ArrayAdapter;
  29. use Symfony\Component\Cache\Adapter\ChainAdapter;
  30. use Symfony\Component\Cache\Adapter\TagAwareAdapter;
  31. use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
  32. use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
  33. use Symfony\Component\Cache\Marshaller\MarshallerInterface;
  34. use Symfony\Component\Cache\ResettableInterface;
  35. use Symfony\Component\Config\FileLocator;
  36. use Symfony\Component\Config\Loader\LoaderInterface;
  37. use Symfony\Component\Config\Resource\DirectoryResource;
  38. use Symfony\Component\Config\ResourceCheckerInterface;
  39. use Symfony\Component\Console\Application;
  40. use Symfony\Component\Console\Command\Command;
  41. use Symfony\Component\DependencyInjection\Alias;
  42. use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  43. use Symfony\Component\DependencyInjection\ChildDefinition;
  44. use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
  45. use Symfony\Component\DependencyInjection\ContainerBuilder;
  46. use Symfony\Component\DependencyInjection\ContainerInterface;
  47. use Symfony\Component\DependencyInjection\Definition;
  48. use Symfony\Component\DependencyInjection\EnvVarLoaderInterface;
  49. use Symfony\Component\DependencyInjection\EnvVarProcessorInterface;
  50. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  51. use Symfony\Component\DependencyInjection\Exception\LogicException;
  52. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  53. use Symfony\Component\DependencyInjection\Parameter;
  54. use Symfony\Component\DependencyInjection\Reference;
  55. use Symfony\Component\DependencyInjection\ServiceLocator;
  56. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  57. use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
  58. use Symfony\Component\Finder\Finder;
  59. use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
  60. use Symfony\Component\Form\FormTypeExtensionInterface;
  61. use Symfony\Component\Form\FormTypeGuesserInterface;
  62. use Symfony\Component\Form\FormTypeInterface;
  63. use Symfony\Component\HttpClient\ScopingHttpClient;
  64. use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
  65. use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
  66. use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
  67. use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
  68. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  69. use Symfony\Component\Lock\Lock;
  70. use Symfony\Component\Lock\LockFactory;
  71. use Symfony\Component\Lock\LockInterface;
  72. use Symfony\Component\Lock\PersistingStoreInterface;
  73. use Symfony\Component\Lock\Store\StoreFactory;
  74. use Symfony\Component\Lock\StoreInterface;
  75. use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
  76. use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
  77. use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
  78. use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory;
  79. use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory;
  80. use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory;
  81. use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory;
  82. use Symfony\Component\Mailer\Mailer;
  83. use Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\AmazonSqsTransportFactory;
  84. use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpTransportFactory;
  85. use Symfony\Component\Messenger\Bridge\Redis\Transport\RedisTransportFactory;
  86. use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
  87. use Symfony\Component\Messenger\MessageBus;
  88. use Symfony\Component\Messenger\MessageBusInterface;
  89. use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
  90. use Symfony\Component\Messenger\Transport\TransportInterface;
  91. use Symfony\Component\Mime\MimeTypeGuesserInterface;
  92. use Symfony\Component\Mime\MimeTypes;
  93. use Symfony\Component\Notifier\Bridge\Firebase\FirebaseTransportFactory;
  94. use Symfony\Component\Notifier\Bridge\FreeMobile\FreeMobileTransportFactory;
  95. use Symfony\Component\Notifier\Bridge\Mattermost\MattermostTransportFactory;
  96. use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory;
  97. use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransportFactory;
  98. use Symfony\Component\Notifier\Bridge\RocketChat\RocketChatTransportFactory;
  99. use Symfony\Component\Notifier\Bridge\Sinch\SinchTransportFactory;
  100. use Symfony\Component\Notifier\Bridge\Slack\SlackTransportFactory;
  101. use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransportFactory;
  102. use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory;
  103. use Symfony\Component\Notifier\Notifier;
  104. use Symfony\Component\Notifier\Recipient\AdminRecipient;
  105. use Symfony\Component\PropertyAccess\PropertyAccessor;
  106. use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
  107. use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface;
  108. use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
  109. use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface;
  110. use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
  111. use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
  112. use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
  113. use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;
  114. use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
  115. use Symfony\Component\Routing\Loader\AnnotationFileLoader;
  116. use Symfony\Component\Security\Core\Security;
  117. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  118. use Symfony\Component\Serializer\Encoder\DecoderInterface;
  119. use Symfony\Component\Serializer\Encoder\EncoderInterface;
  120. use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  121. use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  122. use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
  123. use Symfony\Component\Stopwatch\Stopwatch;
  124. use Symfony\Component\String\LazyString;
  125. use Symfony\Component\String\Slugger\SluggerInterface;
  126. use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
  127. use Symfony\Component\Translation\Translator;
  128. use Symfony\Component\Validator\ConstraintValidatorInterface;
  129. use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
  130. use Symfony\Component\Validator\ObjectInitializerInterface;
  131. use Symfony\Component\WebLink\HttpHeaderSerializer;
  132. use Symfony\Component\Workflow;
  133. use Symfony\Component\Workflow\WorkflowInterface;
  134. use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
  135. use Symfony\Component\Yaml\Yaml;
  136. use Symfony\Contracts\Cache\CacheInterface;
  137. use Symfony\Contracts\Cache\TagAwareCacheInterface;
  138. use Symfony\Contracts\HttpClient\HttpClientInterface;
  139. use Symfony\Contracts\Service\ResetInterface;
  140. use Symfony\Contracts\Service\ServiceSubscriberInterface;
  141. use Symfony\Contracts\Translation\LocaleAwareInterface;
  142. /**
  143.  * FrameworkExtension.
  144.  *
  145.  * @author Fabien Potencier <fabien@symfony.com>
  146.  * @author Jeremy Mikola <jmikola@gmail.com>
  147.  * @author Kévin Dunglas <dunglas@gmail.com>
  148.  * @author Grégoire Pineau <lyrixx@lyrixx.info>
  149.  */
  150. class FrameworkExtension extends Extension
  151. {
  152.     private $formConfigEnabled false;
  153.     private $translationConfigEnabled false;
  154.     private $sessionConfigEnabled false;
  155.     private $annotationsConfigEnabled false;
  156.     private $validatorConfigEnabled false;
  157.     private $messengerConfigEnabled false;
  158.     private $mailerConfigEnabled false;
  159.     private $httpClientConfigEnabled false;
  160.     /**
  161.      * Responds to the app.config configuration parameter.
  162.      *
  163.      * @throws LogicException
  164.      */
  165.     public function load(array $configsContainerBuilder $container)
  166.     {
  167.         $loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
  168.         $loader->load('web.xml');
  169.         $loader->load('services.xml');
  170.         $loader->load('fragment_renderer.xml');
  171.         $loader->load('error_renderer.xml');
  172.         if (interface_exists(PsrEventDispatcherInterface::class)) {
  173.             $container->setAlias(PsrEventDispatcherInterface::class, 'event_dispatcher');
  174.         }
  175.         $container->registerAliasForArgument('parameter_bag'PsrContainerInterface::class);
  176.         if (class_exists(Application::class)) {
  177.             $loader->load('console.xml');
  178.             if (!class_exists(BaseXliffLintCommand::class)) {
  179.                 $container->removeDefinition('console.command.xliff_lint');
  180.             }
  181.             if (!class_exists(BaseYamlLintCommand::class)) {
  182.                 $container->removeDefinition('console.command.yaml_lint');
  183.             }
  184.         }
  185.         // Load Cache configuration first as it is used by other components
  186.         $loader->load('cache.xml');
  187.         $configuration $this->getConfiguration($configs$container);
  188.         $config $this->processConfiguration($configuration$configs);
  189.         $this->annotationsConfigEnabled $this->isConfigEnabled($container$config['annotations']);
  190.         $this->translationConfigEnabled $this->isConfigEnabled($container$config['translator']);
  191.         // A translator must always be registered (as support is included by
  192.         // default in the Form and Validator component). If disabled, an identity
  193.         // translator will be used and everything will still work as expected.
  194.         if ($this->isConfigEnabled($container$config['translator']) || $this->isConfigEnabled($container$config['form']) || $this->isConfigEnabled($container$config['validation'])) {
  195.             if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container$config['translator'])) {
  196.                 throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
  197.             }
  198.             if (class_exists(Translator::class)) {
  199.                 $loader->load('identity_translator.xml');
  200.             }
  201.         }
  202.         // If the slugger is used but the String component is not available, we should throw an error
  203.         if (!interface_exists(SluggerInterface::class)) {
  204.             $container->register('slugger''stdClass')
  205.                 ->addError('You cannot use the "slugger" service since the String component is not installed. Try running "composer require symfony/string".');
  206.         } else {
  207.             if (!interface_exists(LocaleAwareInterface::class)) {
  208.                 $container->register('slugger''stdClass')
  209.                     ->addError('You cannot use the "slugger" service since the Translation contracts are not installed. Try running "composer require symfony/translation".');
  210.             }
  211.             if (!\extension_loaded('intl') && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
  212.                 trigger_deprecation('''''Please install the "intl" PHP extension for best performance.');
  213.             }
  214.         }
  215.         if (isset($config['secret'])) {
  216.             $container->setParameter('kernel.secret'$config['secret']);
  217.         }
  218.         $container->setParameter('kernel.http_method_override'$config['http_method_override']);
  219.         $container->setParameter('kernel.trusted_hosts'$config['trusted_hosts']);
  220.         $container->setParameter('kernel.default_locale'$config['default_locale']);
  221.         $container->setParameter('kernel.error_controller'$config['error_controller']);
  222.         if (!$container->hasParameter('debug.file_link_format')) {
  223.             $links = [
  224.                 'textmate' => 'txmt://open?url=file://%%f&line=%%l',
  225.                 'macvim' => 'mvim://open?url=file://%%f&line=%%l',
  226.                 'emacs' => 'emacs://open?url=file://%%f&line=%%l',
  227.                 'sublime' => 'subl://open?url=file://%%f&line=%%l',
  228.                 'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
  229.                 'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
  230.                 'vscode' => 'vscode://file/%%f:%%l',
  231.             ];
  232.             $ide $config['ide'];
  233.             // mark any env vars found in the ide setting as used
  234.             $container->resolveEnvPlaceholders($ide);
  235.             $container->setParameter('debug.file_link_format'str_replace('%''%%'ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide));
  236.         }
  237.         if (!empty($config['test'])) {
  238.             $loader->load('test.xml');
  239.             if (!class_exists(AbstractBrowser::class)) {
  240.                 $container->removeDefinition('test.client');
  241.             }
  242.         }
  243.         // register cache before session so both can share the connection services
  244.         $this->registerCacheConfiguration($config['cache'], $container);
  245.         if ($this->isConfigEnabled($container$config['session'])) {
  246.             if (!\extension_loaded('session')) {
  247.                 throw new LogicException('Session support cannot be enabled as the session extension is not installed. See https://php.net/session.installation for instructions.');
  248.             }
  249.             $this->sessionConfigEnabled true;
  250.             $this->registerSessionConfiguration($config['session'], $container$loader);
  251.             if (!empty($config['test'])) {
  252.                 $container->getDefinition('test.session.listener')->setArgument(1'%session.storage.options%');
  253.             }
  254.         }
  255.         if ($this->isConfigEnabled($container$config['request'])) {
  256.             $this->registerRequestConfiguration($config['request'], $container$loader);
  257.         }
  258.         if (null === $config['csrf_protection']['enabled']) {
  259.             $config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class);
  260.         }
  261.         $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container$loader);
  262.         if ($this->isConfigEnabled($container$config['form'])) {
  263.             if (!class_exists('Symfony\Component\Form\Form')) {
  264.                 throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
  265.             }
  266.             $this->formConfigEnabled true;
  267.             $this->registerFormConfiguration($config$container$loader);
  268.             if (class_exists('Symfony\Component\Validator\Validation')) {
  269.                 $config['validation']['enabled'] = true;
  270.             } else {
  271.                 $container->setParameter('validator.translation_domain''validators');
  272.                 $container->removeDefinition('form.type_extension.form.validator');
  273.                 $container->removeDefinition('form.type_guesser.validator');
  274.             }
  275.         } else {
  276.             $container->removeDefinition('console.command.form_debug');
  277.         }
  278.         if ($this->isConfigEnabled($container$config['assets'])) {
  279.             if (!class_exists('Symfony\Component\Asset\Package')) {
  280.                 throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
  281.             }
  282.             $this->registerAssetsConfiguration($config['assets'], $container$loader);
  283.         }
  284.         if ($this->messengerConfigEnabled $this->isConfigEnabled($container$config['messenger'])) {
  285.             $this->registerMessengerConfiguration($config['messenger'], $container$loader$config['validation']);
  286.         } else {
  287.             $container->removeDefinition('console.command.messenger_consume_messages');
  288.             $container->removeDefinition('console.command.messenger_debug');
  289.             $container->removeDefinition('console.command.messenger_stop_workers');
  290.             $container->removeDefinition('console.command.messenger_setup_transports');
  291.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  292.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  293.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  294.             $container->removeDefinition('cache.messenger.restart_workers_signal');
  295.             if ($container->hasDefinition('messenger.transport.amqp.factory') && !class_exists(AmqpTransportFactory::class)) {
  296.                 if (class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory::class)) {
  297.                     $container->getDefinition('messenger.transport.amqp.factory')
  298.                         ->setClass(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory::class)
  299.                         ->addTag('messenger.transport_factory');
  300.                 } else {
  301.                     $container->removeDefinition('messenger.transport.amqp.factory');
  302.                 }
  303.             }
  304.             if ($container->hasDefinition('messenger.transport.redis.factory') && !class_exists(RedisTransportFactory::class)) {
  305.                 if (class_exists(\Symfony\Component\Messenger\Transport\RedisExt\RedisTransportFactory::class)) {
  306.                     $container->getDefinition('messenger.transport.redis.factory')
  307.                         ->setClass(\Symfony\Component\Messenger\Transport\RedisExt\RedisTransportFactory::class)
  308.                         ->addTag('messenger.transport_factory');
  309.                 } else {
  310.                     $container->removeDefinition('messenger.transport.redis.factory');
  311.                 }
  312.             }
  313.         }
  314.         if ($this->httpClientConfigEnabled $this->isConfigEnabled($container$config['http_client'])) {
  315.             $this->registerHttpClientConfiguration($config['http_client'], $container$loader$config['profiler']);
  316.         }
  317.         if ($this->mailerConfigEnabled $this->isConfigEnabled($container$config['mailer'])) {
  318.             $this->registerMailerConfiguration($config['mailer'], $container$loader);
  319.         }
  320.         if ($this->isConfigEnabled($container$config['notifier'])) {
  321.             $this->registerNotifierConfiguration($config['notifier'], $container$loader);
  322.         }
  323.         $propertyInfoEnabled $this->isConfigEnabled($container$config['property_info']);
  324.         $this->registerValidationConfiguration($config['validation'], $container$loader$propertyInfoEnabled);
  325.         $this->registerEsiConfiguration($config['esi'], $container$loader);
  326.         $this->registerSsiConfiguration($config['ssi'], $container$loader);
  327.         $this->registerFragmentsConfiguration($config['fragments'], $container$loader);
  328.         $this->registerTranslatorConfiguration($config['translator'], $container$loader$config['default_locale']);
  329.         $this->registerProfilerConfiguration($config['profiler'], $container$loader);
  330.         $this->registerWorkflowConfiguration($config['workflows'], $container$loader);
  331.         $this->registerDebugConfiguration($config['php_errors'], $container$loader);
  332.         $this->registerRouterConfiguration($config['router'], $container$loader$config['translator']['enabled_locales'] ?? []);
  333.         $this->registerAnnotationsConfiguration($config['annotations'], $container$loader);
  334.         $this->registerPropertyAccessConfiguration($config['property_access'], $container$loader);
  335.         $this->registerSecretsConfiguration($config['secrets'], $container$loader);
  336.         if ($this->isConfigEnabled($container$config['serializer'])) {
  337.             if (!class_exists('Symfony\Component\Serializer\Serializer')) {
  338.                 throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
  339.             }
  340.             $this->registerSerializerConfiguration($config['serializer'], $container$loader);
  341.         }
  342.         if ($propertyInfoEnabled) {
  343.             $this->registerPropertyInfoConfiguration($container$loader);
  344.         }
  345.         if ($this->isConfigEnabled($container$config['lock'])) {
  346.             $this->registerLockConfiguration($config['lock'], $container$loader);
  347.         }
  348.         if ($this->isConfigEnabled($container$config['web_link'])) {
  349.             if (!class_exists(HttpHeaderSerializer::class)) {
  350.                 throw new LogicException('WebLink support cannot be enabled as the WebLink component is not installed. Try running "composer require symfony/weblink".');
  351.             }
  352.             $loader->load('web_link.xml');
  353.         }
  354.         $this->addAnnotatedClassesToCompile([
  355.             '**\\Controller\\',
  356.             '**\\Entity\\',
  357.             // Added explicitly so that we don't rely on the class map being dumped to make it work
  358.             'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController',
  359.         ]);
  360.         if (class_exists(MimeTypes::class)) {
  361.             $loader->load('mime_type.xml');
  362.         }
  363.         $container->registerForAutoconfiguration(Command::class)
  364.             ->addTag('console.command');
  365.         $container->registerForAutoconfiguration(ResourceCheckerInterface::class)
  366.             ->addTag('config_cache.resource_checker');
  367.         $container->registerForAutoconfiguration(EnvVarLoaderInterface::class)
  368.             ->addTag('container.env_var_loader');
  369.         $container->registerForAutoconfiguration(EnvVarProcessorInterface::class)
  370.             ->addTag('container.env_var_processor');
  371.         $container->registerForAutoconfiguration(ServiceLocator::class)
  372.             ->addTag('container.service_locator');
  373.         $container->registerForAutoconfiguration(ServiceSubscriberInterface::class)
  374.             ->addTag('container.service_subscriber');
  375.         $container->registerForAutoconfiguration(ArgumentValueResolverInterface::class)
  376.             ->addTag('controller.argument_value_resolver');
  377.         $container->registerForAutoconfiguration(AbstractController::class)
  378.             ->addTag('controller.service_arguments');
  379.         $container->registerForAutoconfiguration(DataCollectorInterface::class)
  380.             ->addTag('data_collector');
  381.         $container->registerForAutoconfiguration(FormTypeInterface::class)
  382.             ->addTag('form.type');
  383.         $container->registerForAutoconfiguration(FormTypeGuesserInterface::class)
  384.             ->addTag('form.type_guesser');
  385.         $container->registerForAutoconfiguration(FormTypeExtensionInterface::class)
  386.             ->addTag('form.type_extension');
  387.         $container->registerForAutoconfiguration(CacheClearerInterface::class)
  388.             ->addTag('kernel.cache_clearer');
  389.         $container->registerForAutoconfiguration(CacheWarmerInterface::class)
  390.             ->addTag('kernel.cache_warmer');
  391.         $container->registerForAutoconfiguration(EventSubscriberInterface::class)
  392.             ->addTag('kernel.event_subscriber');
  393.         $container->registerForAutoconfiguration(LocaleAwareInterface::class)
  394.             ->addTag('kernel.locale_aware');
  395.         $container->registerForAutoconfiguration(ResetInterface::class)
  396.             ->addTag('kernel.reset', ['method' => 'reset']);
  397.         if (!interface_exists(MarshallerInterface::class)) {
  398.             $container->registerForAutoconfiguration(ResettableInterface::class)
  399.                 ->addTag('kernel.reset', ['method' => 'reset']);
  400.         }
  401.         $container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
  402.             ->addTag('property_info.list_extractor');
  403.         $container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
  404.             ->addTag('property_info.type_extractor');
  405.         $container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class)
  406.             ->addTag('property_info.description_extractor');
  407.         $container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class)
  408.             ->addTag('property_info.access_extractor');
  409.         $container->registerForAutoconfiguration(PropertyInitializableExtractorInterface::class)
  410.             ->addTag('property_info.initializable_extractor');
  411.         $container->registerForAutoconfiguration(EncoderInterface::class)
  412.             ->addTag('serializer.encoder');
  413.         $container->registerForAutoconfiguration(DecoderInterface::class)
  414.             ->addTag('serializer.encoder');
  415.         $container->registerForAutoconfiguration(NormalizerInterface::class)
  416.             ->addTag('serializer.normalizer');
  417.         $container->registerForAutoconfiguration(DenormalizerInterface::class)
  418.             ->addTag('serializer.normalizer');
  419.         $container->registerForAutoconfiguration(ConstraintValidatorInterface::class)
  420.             ->addTag('validator.constraint_validator');
  421.         $container->registerForAutoconfiguration(ObjectInitializerInterface::class)
  422.             ->addTag('validator.initializer');
  423.         $container->registerForAutoconfiguration(MessageHandlerInterface::class)
  424.             ->addTag('messenger.message_handler');
  425.         $container->registerForAutoconfiguration(TransportFactoryInterface::class)
  426.             ->addTag('messenger.transport_factory');
  427.         $container->registerForAutoconfiguration(MimeTypeGuesserInterface::class)
  428.             ->addTag('mime.mime_type_guesser');
  429.         $container->registerForAutoconfiguration(LoggerAwareInterface::class)
  430.             ->addMethodCall('setLogger', [new Reference('logger')]);
  431.         if (!$container->getParameter('kernel.debug')) {
  432.             // remove tagged iterator argument for resource checkers
  433.             $container->getDefinition('config_cache_factory')->setArguments([]);
  434.         }
  435.         if (!$config['disallow_search_engine_index'] ?? false) {
  436.             $container->removeDefinition('disallow_search_engine_index_response_listener');
  437.         }
  438.         $container->registerForAutoconfiguration(RouteLoaderInterface::class)
  439.             ->addTag('routing.route_loader');
  440.     }
  441.     /**
  442.      * {@inheritdoc}
  443.      */
  444.     public function getConfiguration(array $configContainerBuilder $container)
  445.     {
  446.         return new Configuration($container->getParameter('kernel.debug'));
  447.     }
  448.     private function registerFormConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  449.     {
  450.         $loader->load('form.xml');
  451.         if (null === $config['form']['csrf_protection']['enabled']) {
  452.             $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
  453.         }
  454.         if ($this->isConfigEnabled($container$config['form']['csrf_protection'])) {
  455.             $loader->load('form_csrf.xml');
  456.             $container->setParameter('form.type_extension.csrf.enabled'true);
  457.             $container->setParameter('form.type_extension.csrf.field_name'$config['form']['csrf_protection']['field_name']);
  458.         } else {
  459.             $container->setParameter('form.type_extension.csrf.enabled'false);
  460.         }
  461.         if (!class_exists(Translator::class)) {
  462.             $container->removeDefinition('form.type_extension.upload.validator');
  463.         }
  464.         if (!method_exists(CachingFactoryDecorator::class, 'reset')) {
  465.             $container->getDefinition('form.choice_list_factory.cached')
  466.                 ->clearTag('kernel.reset')
  467.             ;
  468.         }
  469.     }
  470.     private function registerEsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  471.     {
  472.         if (!$this->isConfigEnabled($container$config)) {
  473.             $container->removeDefinition('fragment.renderer.esi');
  474.             return;
  475.         }
  476.         $loader->load('esi.xml');
  477.     }
  478.     private function registerSsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  479.     {
  480.         if (!$this->isConfigEnabled($container$config)) {
  481.             $container->removeDefinition('fragment.renderer.ssi');
  482.             return;
  483.         }
  484.         $loader->load('ssi.xml');
  485.     }
  486.     private function registerFragmentsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  487.     {
  488.         if (!$this->isConfigEnabled($container$config)) {
  489.             $container->removeDefinition('fragment.renderer.hinclude');
  490.             return;
  491.         }
  492.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  493.         $loader->load('fragment_listener.xml');
  494.         $container->setParameter('fragment.path'$config['path']);
  495.     }
  496.     private function registerProfilerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  497.     {
  498.         if (!$this->isConfigEnabled($container$config)) {
  499.             // this is needed for the WebProfiler to work even if the profiler is disabled
  500.             $container->setParameter('data_collector.templates', []);
  501.             return;
  502.         }
  503.         $loader->load('profiling.xml');
  504.         $loader->load('collectors.xml');
  505.         $loader->load('cache_debug.xml');
  506.         if ($this->formConfigEnabled) {
  507.             $loader->load('form_debug.xml');
  508.         }
  509.         if ($this->validatorConfigEnabled) {
  510.             $loader->load('validator_debug.xml');
  511.         }
  512.         if ($this->translationConfigEnabled) {
  513.             $loader->load('translation_debug.xml');
  514.             $container->getDefinition('translator.data_collector')->setDecoratedService('translator');
  515.         }
  516.         if ($this->messengerConfigEnabled) {
  517.             $loader->load('messenger_debug.xml');
  518.         }
  519.         if ($this->mailerConfigEnabled) {
  520.             $loader->load('mailer_debug.xml');
  521.         }
  522.         if ($this->httpClientConfigEnabled) {
  523.             $loader->load('http_client_debug.xml');
  524.         }
  525.         $container->setParameter('profiler_listener.only_exceptions'$config['only_exceptions']);
  526.         $container->setParameter('profiler_listener.only_master_requests'$config['only_master_requests']);
  527.         // Choose storage class based on the DSN
  528.         list($class) = explode(':'$config['dsn'], 2);
  529.         if ('file' !== $class) {
  530.             throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.'$class));
  531.         }
  532.         $container->setParameter('profiler.storage.dsn'$config['dsn']);
  533.         $container->getDefinition('profiler')
  534.             ->addArgument($config['collect'])
  535.             ->addTag('kernel.reset', ['method' => 'reset']);
  536.     }
  537.     private function registerWorkflowConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  538.     {
  539.         if (!$config['enabled']) {
  540.             $container->removeDefinition('console.command.workflow_dump');
  541.             return;
  542.         }
  543.         if (!class_exists(Workflow\Workflow::class)) {
  544.             throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed. Try running "composer require symfony/workflow".');
  545.         }
  546.         $loader->load('workflow.xml');
  547.         $registryDefinition $container->getDefinition('workflow.registry');
  548.         foreach ($config['workflows'] as $name => $workflow) {
  549.             $type $workflow['type'];
  550.             $workflowId sprintf('%s.%s'$type$name);
  551.             // Process Metadata (workflow + places (transition is done in the "create transition" block))
  552.             $metadataStoreDefinition = new Definition(Workflow\Metadata\InMemoryMetadataStore::class, [[], [], null]);
  553.             if ($workflow['metadata']) {
  554.                 $metadataStoreDefinition->replaceArgument(0$workflow['metadata']);
  555.             }
  556.             $placesMetadata = [];
  557.             foreach ($workflow['places'] as $place) {
  558.                 if ($place['metadata']) {
  559.                     $placesMetadata[$place['name']] = $place['metadata'];
  560.                 }
  561.             }
  562.             if ($placesMetadata) {
  563.                 $metadataStoreDefinition->replaceArgument(1$placesMetadata);
  564.             }
  565.             // Create transitions
  566.             $transitions = [];
  567.             $guardsConfiguration = [];
  568.             $transitionsMetadataDefinition = new Definition(\SplObjectStorage::class);
  569.             // Global transition counter per workflow
  570.             $transitionCounter 0;
  571.             foreach ($workflow['transitions'] as $transition) {
  572.                 if ('workflow' === $type) {
  573.                     $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]);
  574.                     $transitionDefinition->setPublic(false);
  575.                     $transitionId sprintf('.%s.transition.%s'$workflowId$transitionCounter++);
  576.                     $container->setDefinition($transitionId$transitionDefinition);
  577.                     $transitions[] = new Reference($transitionId);
  578.                     if (isset($transition['guard'])) {
  579.                         $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  580.                         $configuration->addArgument(new Reference($transitionId));
  581.                         $configuration->addArgument($transition['guard']);
  582.                         $configuration->setPublic(false);
  583.                         $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  584.                         $guardsConfiguration[$eventName][] = $configuration;
  585.                     }
  586.                     if ($transition['metadata']) {
  587.                         $transitionsMetadataDefinition->addMethodCall('attach', [
  588.                             new Reference($transitionId),
  589.                             $transition['metadata'],
  590.                         ]);
  591.                     }
  592.                 } elseif ('state_machine' === $type) {
  593.                     foreach ($transition['from'] as $from) {
  594.                         foreach ($transition['to'] as $to) {
  595.                             $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from$to]);
  596.                             $transitionDefinition->setPublic(false);
  597.                             $transitionId sprintf('.%s.transition.%s'$workflowId$transitionCounter++);
  598.                             $container->setDefinition($transitionId$transitionDefinition);
  599.                             $transitions[] = new Reference($transitionId);
  600.                             if (isset($transition['guard'])) {
  601.                                 $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  602.                                 $configuration->addArgument(new Reference($transitionId));
  603.                                 $configuration->addArgument($transition['guard']);
  604.                                 $configuration->setPublic(false);
  605.                                 $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  606.                                 $guardsConfiguration[$eventName][] = $configuration;
  607.                             }
  608.                             if ($transition['metadata']) {
  609.                                 $transitionsMetadataDefinition->addMethodCall('attach', [
  610.                                     new Reference($transitionId),
  611.                                     $transition['metadata'],
  612.                                 ]);
  613.                             }
  614.                         }
  615.                     }
  616.                 }
  617.             }
  618.             $metadataStoreDefinition->replaceArgument(2$transitionsMetadataDefinition);
  619.             // Create places
  620.             $places array_column($workflow['places'], 'name');
  621.             $initialMarking $workflow['initial_marking'] ?? [];
  622.             // Create a Definition
  623.             $definitionDefinition = new Definition(Workflow\Definition::class);
  624.             $definitionDefinition->setPublic(false);
  625.             $definitionDefinition->addArgument($places);
  626.             $definitionDefinition->addArgument($transitions);
  627.             $definitionDefinition->addArgument($initialMarking);
  628.             $definitionDefinition->addArgument($metadataStoreDefinition);
  629.             $definitionDefinition->addTag('workflow.definition', [
  630.                 'name' => $name,
  631.                 'type' => $type,
  632.             ]);
  633.             // Create MarkingStore
  634.             if (isset($workflow['marking_store']['type'])) {
  635.                 $markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
  636.                 $markingStoreDefinition->setArguments([
  637.                     'state_machine' === $type//single state
  638.                     $workflow['marking_store']['property'],
  639.                 ]);
  640.             } elseif (isset($workflow['marking_store']['service'])) {
  641.                 $markingStoreDefinition = new Reference($workflow['marking_store']['service']);
  642.             }
  643.             // Create Workflow
  644.             $workflowDefinition = new ChildDefinition(sprintf('%s.abstract'$type));
  645.             $workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition'$workflowId)));
  646.             if (isset($markingStoreDefinition)) {
  647.                 $workflowDefinition->replaceArgument(1$markingStoreDefinition);
  648.             }
  649.             $workflowDefinition->replaceArgument(3$name);
  650.             // Store to container
  651.             $container->setDefinition($workflowId$workflowDefinition);
  652.             $container->setDefinition(sprintf('%s.definition'$workflowId), $definitionDefinition);
  653.             $container->registerAliasForArgument($workflowIdWorkflowInterface::class, $name.'.'.$type);
  654.             // Validate Workflow
  655.             if ('state_machine' === $workflow['type']) {
  656.                 $validator = new Workflow\Validator\StateMachineValidator();
  657.             } else {
  658.                 $validator = new Workflow\Validator\WorkflowValidator();
  659.             }
  660.             $trs array_map(function (Reference $ref) use ($container): Workflow\Transition {
  661.                 return $container->get((string) $ref);
  662.             }, $transitions);
  663.             $realDefinition = new Workflow\Definition($places$trs$initialMarking);
  664.             $validator->validate($realDefinition$name);
  665.             // Add workflow to Registry
  666.             if ($workflow['supports']) {
  667.                 foreach ($workflow['supports'] as $supportedClassName) {
  668.                     $strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, [$supportedClassName]);
  669.                     $strategyDefinition->setPublic(false);
  670.                     $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
  671.                 }
  672.             } elseif (isset($workflow['support_strategy'])) {
  673.                 $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), new Reference($workflow['support_strategy'])]);
  674.             }
  675.             // Enable the AuditTrail
  676.             if ($workflow['audit_trail']['enabled']) {
  677.                 $listener = new Definition(Workflow\EventListener\AuditTrailListener::class);
  678.                 $listener->setPrivate(true);
  679.                 $listener->addTag('monolog.logger', ['channel' => 'workflow']);
  680.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave'$name), 'method' => 'onLeave']);
  681.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition'$name), 'method' => 'onTransition']);
  682.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter'$name), 'method' => 'onEnter']);
  683.                 $listener->addArgument(new Reference('logger'));
  684.                 $container->setDefinition(sprintf('.%s.listener.audit_trail'$workflowId), $listener);
  685.             }
  686.             // Add Guard Listener
  687.             if ($guardsConfiguration) {
  688.                 if (!class_exists(ExpressionLanguage::class)) {
  689.                     throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
  690.                 }
  691.                 if (!class_exists(Security::class)) {
  692.                     throw new LogicException('Cannot guard workflows as the Security component is not installed. Try running "composer require symfony/security-core".');
  693.                 }
  694.                 $guard = new Definition(Workflow\EventListener\GuardListener::class);
  695.                 $guard->setPrivate(true);
  696.                 $guard->setArguments([
  697.                     $guardsConfiguration,
  698.                     new Reference('workflow.security.expression_language'),
  699.                     new Reference('security.token_storage'),
  700.                     new Reference('security.authorization_checker'),
  701.                     new Reference('security.authentication.trust_resolver'),
  702.                     new Reference('security.role_hierarchy'),
  703.                     new Reference('validator'ContainerInterface::NULL_ON_INVALID_REFERENCE),
  704.                 ]);
  705.                 foreach ($guardsConfiguration as $eventName => $config) {
  706.                     $guard->addTag('kernel.event_listener', ['event' => $eventName'method' => 'onTransition']);
  707.                 }
  708.                 $container->setDefinition(sprintf('.%s.listener.guard'$workflowId), $guard);
  709.                 $container->setParameter('workflow.has_guard_listeners'true);
  710.             }
  711.         }
  712.     }
  713.     private function registerDebugConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  714.     {
  715.         $loader->load('debug_prod.xml');
  716.         if (class_exists(Stopwatch::class)) {
  717.             $container->register('debug.stopwatch'Stopwatch::class)
  718.                 ->addArgument(true)
  719.                 ->setPrivate(true)
  720.                 ->addTag('kernel.reset', ['method' => 'reset']);
  721.             $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch'false));
  722.         }
  723.         $debug $container->getParameter('kernel.debug');
  724.         if ($debug) {
  725.             $container->setParameter('debug.container.dump''%kernel.cache_dir%/%kernel.container_class%.xml');
  726.         }
  727.         if ($debug && class_exists(Stopwatch::class)) {
  728.             $loader->load('debug.xml');
  729.         }
  730.         $definition $container->findDefinition('debug.debug_handlers_listener');
  731.         if (false === $config['log']) {
  732.             $definition->replaceArgument(1null);
  733.         } elseif (true !== $config['log']) {
  734.             $definition->replaceArgument(2$config['log']);
  735.         }
  736.         if (!$config['throw']) {
  737.             $container->setParameter('debug.error_handler.throw_at'0);
  738.         }
  739.         if ($debug && class_exists(DebugProcessor::class)) {
  740.             $definition = new Definition(DebugProcessor::class);
  741.             $definition->setPublic(false);
  742.             $definition->addArgument(new Reference('request_stack'));
  743.             $container->setDefinition('debug.log_processor'$definition);
  744.         }
  745.     }
  746.     private function registerRouterConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $enabledLocales = [])
  747.     {
  748.         if (!$this->isConfigEnabled($container$config)) {
  749.             $container->removeDefinition('console.command.router_debug');
  750.             $container->removeDefinition('console.command.router_match');
  751.             return;
  752.         }
  753.         $loader->load('routing.xml');
  754.         if (null === $config['utf8']) {
  755.             trigger_deprecation('symfony/framework-bundle''5.1''Not setting the "framework.router.utf8" configuration option is deprecated, it will default to "true" in version 6.0.');
  756.         }
  757.         if ($config['utf8']) {
  758.             $container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
  759.         }
  760.         if ($enabledLocales) {
  761.             $enabledLocales implode('|'array_map('preg_quote'$enabledLocales));
  762.             $container->getDefinition('routing.loader')->replaceArgument(2, ['_locale' => $enabledLocales]);
  763.         }
  764.         if (!class_exists(ExpressionLanguage::class)) {
  765.             $container->removeDefinition('router.expression_language_provider');
  766.         }
  767.         $container->setParameter('router.resource'$config['resource']);
  768.         $router $container->findDefinition('router.default');
  769.         $argument $router->getArgument(2);
  770.         $argument['strict_requirements'] = $config['strict_requirements'];
  771.         if (isset($config['type'])) {
  772.             $argument['resource_type'] = $config['type'];
  773.         }
  774.         $router->replaceArgument(2$argument);
  775.         $container->setParameter('request_listener.http_port'$config['http_port']);
  776.         $container->setParameter('request_listener.https_port'$config['https_port']);
  777.         if (null !== $config['default_uri']) {
  778.             $container->getDefinition('router.request_context')
  779.                 ->replaceArgument(0$config['default_uri']);
  780.         }
  781.         if ($this->annotationsConfigEnabled) {
  782.             $container->register('routing.loader.annotation'AnnotatedRouteControllerLoader::class)
  783.                 ->setPublic(false)
  784.                 ->addTag('routing.loader', ['priority' => -10])
  785.                 ->addArgument(new Reference('annotation_reader'));
  786.             $container->register('routing.loader.annotation.directory'AnnotationDirectoryLoader::class)
  787.                 ->setPublic(false)
  788.                 ->addTag('routing.loader', ['priority' => -10])
  789.                 ->setArguments([
  790.                     new Reference('file_locator'),
  791.                     new Reference('routing.loader.annotation'),
  792.                 ]);
  793.             $container->register('routing.loader.annotation.file'AnnotationFileLoader::class)
  794.                 ->setPublic(false)
  795.                 ->addTag('routing.loader', ['priority' => -10])
  796.                 ->setArguments([
  797.                     new Reference('file_locator'),
  798.                     new Reference('routing.loader.annotation'),
  799.                 ]);
  800.         }
  801.     }
  802.     private function registerSessionConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  803.     {
  804.         $loader->load('session.xml');
  805.         // session storage
  806.         $container->setAlias('session.storage'$config['storage_id'])->setPrivate(true);
  807.         $options = ['cache_limiter' => '0'];
  808.         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) {
  809.             if (isset($config[$key])) {
  810.                 $options[$key] = $config[$key];
  811.             }
  812.         }
  813.         if ('auto' === ($options['cookie_secure'] ?? null)) {
  814.             $locator $container->getDefinition('session_listener')->getArgument(0);
  815.             $locator->setValues($locator->getValues() + [
  816.                 'session_storage' => new Reference('session.storage'ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
  817.                 'request_stack' => new Reference('request_stack'),
  818.             ]);
  819.         }
  820.         $container->setParameter('session.storage.options'$options);
  821.         // session handler (the internal callback registered with PHP session management)
  822.         if (null === $config['handler_id']) {
  823.             // Set the handler class to be null
  824.             $container->getDefinition('session.storage.native')->replaceArgument(1null);
  825.             $container->getDefinition('session.storage.php_bridge')->replaceArgument(0null);
  826.             $container->setAlias('session.handler''session.handler.native_file')->setPrivate(true);
  827.         } else {
  828.             $container->resolveEnvPlaceholders($config['handler_id'], null$usedEnvs);
  829.             if ($usedEnvs || preg_match('#^[a-z]++://#'$config['handler_id'])) {
  830.                 $id '.cache_connection.'.ContainerBuilder::hash($config['handler_id']);
  831.                 $container->getDefinition('session.abstract_handler')
  832.                     ->replaceArgument(0$container->hasDefinition($id) ? new Reference($id) : $config['handler_id']);
  833.                 $container->setAlias('session.handler''session.abstract_handler')->setPrivate(true);
  834.             } else {
  835.                 $container->setAlias('session.handler'$config['handler_id'])->setPrivate(true);
  836.             }
  837.         }
  838.         $container->setParameter('session.save_path'$config['save_path']);
  839.         $container->setParameter('session.metadata.update_threshold'$config['metadata_update_threshold']);
  840.     }
  841.     private function registerRequestConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  842.     {
  843.         if ($config['formats']) {
  844.             $loader->load('request.xml');
  845.             $listener $container->getDefinition('request.add_request_formats_listener');
  846.             $listener->replaceArgument(0$config['formats']);
  847.         }
  848.     }
  849.     private function registerAssetsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  850.     {
  851.         $loader->load('assets.xml');
  852.         if ($config['version_strategy']) {
  853.             $defaultVersion = new Reference($config['version_strategy']);
  854.         } else {
  855.             $defaultVersion $this->createVersion($container$config['version'], $config['version_format'], $config['json_manifest_path'], '_default');
  856.         }
  857.         $defaultPackage $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
  858.         $container->setDefinition('assets._default_package'$defaultPackage);
  859.         $namedPackages = [];
  860.         foreach ($config['packages'] as $name => $package) {
  861.             if (null !== $package['version_strategy']) {
  862.                 $version = new Reference($package['version_strategy']);
  863.             } elseif (!\array_key_exists('version'$package) && null === $package['json_manifest_path']) {
  864.                 // if neither version nor json_manifest_path are specified, use the default
  865.                 $version $defaultVersion;
  866.             } else {
  867.                 // let format fallback to main version_format
  868.                 $format $package['version_format'] ?: $config['version_format'];
  869.                 $version = isset($package['version']) ? $package['version'] : null;
  870.                 $version $this->createVersion($container$version$format$package['json_manifest_path'], $name);
  871.             }
  872.             $container->setDefinition('assets._package_'.$name$this->createPackageDefinition($package['base_path'], $package['base_urls'], $version));
  873.             $container->registerAliasForArgument('assets._package_'.$namePackageInterface::class, $name.'.package');
  874.             $namedPackages[$name] = new Reference('assets._package_'.$name);
  875.         }
  876.         $container->getDefinition('assets.packages')
  877.             ->replaceArgument(0, new Reference('assets._default_package'))
  878.             ->replaceArgument(1$namedPackages)
  879.         ;
  880.     }
  881.     /**
  882.      * Returns a definition for an asset package.
  883.      */
  884.     private function createPackageDefinition(?string $basePath, array $baseUrlsReference $version): Definition
  885.     {
  886.         if ($basePath && $baseUrls) {
  887.             throw new \LogicException('An asset package cannot have base URLs and base paths.');
  888.         }
  889.         $package = new ChildDefinition($baseUrls 'assets.url_package' 'assets.path_package');
  890.         $package
  891.             ->setPublic(false)
  892.             ->replaceArgument(0$baseUrls ?: $basePath)
  893.             ->replaceArgument(1$version)
  894.         ;
  895.         return $package;
  896.     }
  897.     private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPathstring $name): Reference
  898.     {
  899.         // Configuration prevents $version and $jsonManifestPath from being set
  900.         if (null !== $version) {
  901.             $def = new ChildDefinition('assets.static_version_strategy');
  902.             $def
  903.                 ->replaceArgument(0$version)
  904.                 ->replaceArgument(1$format)
  905.             ;
  906.             $container->setDefinition('assets._version_'.$name$def);
  907.             return new Reference('assets._version_'.$name);
  908.         }
  909.         if (null !== $jsonManifestPath) {
  910.             $definitionName 'assets.json_manifest_version_strategy';
  911.             if (=== strpos(parse_url($jsonManifestPath, \PHP_URL_SCHEME), 'http')) {
  912.                 $definitionName 'assets.remote_json_manifest_version_strategy';
  913.             }
  914.             $def = new ChildDefinition($definitionName);
  915.             $def->replaceArgument(0$jsonManifestPath);
  916.             $container->setDefinition('assets._version_'.$name$def);
  917.             return new Reference('assets._version_'.$name);
  918.         }
  919.         return new Reference('assets.empty_version_strategy');
  920.     }
  921.     private function registerTranslatorConfiguration(array $configContainerBuilder $containerLoaderInterface $loaderstring $defaultLocale)
  922.     {
  923.         if (!$this->isConfigEnabled($container$config)) {
  924.             $container->removeDefinition('console.command.translation_debug');
  925.             $container->removeDefinition('console.command.translation_update');
  926.             return;
  927.         }
  928.         $loader->load('translation.xml');
  929.         // Use the "real" translator instead of the identity default
  930.         $container->setAlias('translator''translator.default')->setPublic(true);
  931.         $container->setAlias('translator.formatter', new Alias($config['formatter'], false));
  932.         $translator $container->findDefinition('translator.default');
  933.         $translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
  934.         $defaultOptions $translator->getArgument(4);
  935.         $defaultOptions['cache_dir'] = $config['cache_dir'];
  936.         $translator->setArgument(4$defaultOptions);
  937.         $translator->setArgument(5$config['enabled_locales']);
  938.         $container->setParameter('translator.logging'$config['logging']);
  939.         $container->setParameter('translator.default_path'$config['default_path']);
  940.         // Discover translation directories
  941.         $dirs = [];
  942.         $transPaths = [];
  943.         $nonExistingDirs = [];
  944.         if (class_exists('Symfony\Component\Validator\Validation')) {
  945.             $r = new \ReflectionClass('Symfony\Component\Validator\Validation');
  946.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  947.         }
  948.         if (class_exists('Symfony\Component\Form\Form')) {
  949.             $r = new \ReflectionClass('Symfony\Component\Form\Form');
  950.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  951.         }
  952.         if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
  953.             $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
  954.             $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
  955.         }
  956.         $defaultDir $container->getParameterBag()->resolveValue($config['default_path']);
  957.         foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
  958.             if ($container->fileExists($dir $bundle['path'].'/Resources/translations') || $container->fileExists($dir $bundle['path'].'/translations')) {
  959.                 $dirs[] = $dir;
  960.             } else {
  961.                 $nonExistingDirs[] = $dir;
  962.             }
  963.         }
  964.         foreach ($config['paths'] as $dir) {
  965.             if ($container->fileExists($dir)) {
  966.                 $dirs[] = $transPaths[] = $dir;
  967.             } else {
  968.                 throw new \UnexpectedValueException(sprintf('"%s" defined in translator.paths does not exist or is not a directory.'$dir));
  969.             }
  970.         }
  971.         if ($container->hasDefinition('console.command.translation_debug')) {
  972.             $container->getDefinition('console.command.translation_debug')->replaceArgument(5$transPaths);
  973.         }
  974.         if ($container->hasDefinition('console.command.translation_update')) {
  975.             $container->getDefinition('console.command.translation_update')->replaceArgument(6$transPaths);
  976.         }
  977.         if ($container->fileExists($defaultDir)) {
  978.             $dirs[] = $defaultDir;
  979.         } else {
  980.             $nonExistingDirs[] = $defaultDir;
  981.         }
  982.         // Register translation resources
  983.         if ($dirs) {
  984.             $files = [];
  985.             $finder Finder::create()
  986.                 ->followLinks()
  987.                 ->files()
  988.                 ->filter(function (\SplFileInfo $file) {
  989.                     return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  990.                 })
  991.                 ->in($dirs)
  992.                 ->sortByName()
  993.             ;
  994.             foreach ($finder as $file) {
  995.                 $fileNameParts explode('.'basename($file));
  996.                 $locale $fileNameParts[\count($fileNameParts) - 2];
  997.                 if (!isset($files[$locale])) {
  998.                     $files[$locale] = [];
  999.                 }
  1000.                 $files[$locale][] = (string) $file;
  1001.             }
  1002.             $projectDir $container->getParameter('kernel.project_dir');
  1003.             $options array_merge(
  1004.                 $translator->getArgument(4),
  1005.                 [
  1006.                     'resource_files' => $files,
  1007.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1008.                     'cache_vary' => [
  1009.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1010.                             return === strpos($dir$projectDir.'/') ? substr($dir+ \strlen($projectDir)) : $dir;
  1011.                         }, $scannedDirectories),
  1012.                     ],
  1013.                 ]
  1014.             );
  1015.             $translator->replaceArgument(4$options);
  1016.         }
  1017.     }
  1018.     private function registerValidationConfiguration(array $configContainerBuilder $containerXmlFileLoader $loaderbool $propertyInfoEnabled)
  1019.     {
  1020.         if (!$this->validatorConfigEnabled $this->isConfigEnabled($container$config)) {
  1021.             return;
  1022.         }
  1023.         if (!class_exists('Symfony\Component\Validator\Validation')) {
  1024.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1025.         }
  1026.         if (!isset($config['email_validation_mode'])) {
  1027.             $config['email_validation_mode'] = 'loose';
  1028.         }
  1029.         $loader->load('validator.xml');
  1030.         $validatorBuilder $container->getDefinition('validator.builder');
  1031.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1032.         $files = ['xml' => [], 'yml' => []];
  1033.         $this->registerValidatorMapping($container$config$files);
  1034.         if (!empty($files['xml'])) {
  1035.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1036.         }
  1037.         if (!empty($files['yml'])) {
  1038.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1039.         }
  1040.         $definition $container->findDefinition('validator.email');
  1041.         $definition->replaceArgument(0$config['email_validation_mode']);
  1042.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1043.             if (!$this->annotationsConfigEnabled) {
  1044.                 throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
  1045.             }
  1046.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
  1047.         }
  1048.         if (\array_key_exists('static_method'$config) && $config['static_method']) {
  1049.             foreach ($config['static_method'] as $methodName) {
  1050.                 $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
  1051.             }
  1052.         }
  1053.         if (!$container->getParameter('kernel.debug')) {
  1054.             $validatorBuilder->addMethodCall('setMappingCache', [new Reference('validator.mapping.cache.adapter')]);
  1055.         }
  1056.         $container->setParameter('validator.auto_mapping'$config['auto_mapping']);
  1057.         if (!$propertyInfoEnabled || !class_exists(PropertyInfoLoader::class)) {
  1058.             $container->removeDefinition('validator.property_info_loader');
  1059.         }
  1060.         $container
  1061.             ->getDefinition('validator.not_compromised_password')
  1062.             ->setArgument(2$config['not_compromised_password']['enabled'])
  1063.             ->setArgument(3$config['not_compromised_password']['endpoint'])
  1064.         ;
  1065.     }
  1066.     private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files)
  1067.     {
  1068.         $fileRecorder = function ($extension$path) use (&$files) {
  1069.             $files['yaml' === $extension 'yml' $extension][] = $path;
  1070.         };
  1071.         if (interface_exists('Symfony\Component\Form\FormInterface')) {
  1072.             $reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
  1073.             $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
  1074.         }
  1075.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1076.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1077.             if (
  1078.                 $container->fileExists($file $configDir.'/validation.yaml'false) ||
  1079.                 $container->fileExists($file $configDir.'/validation.yml'false)
  1080.             ) {
  1081.                 $fileRecorder('yml'$file);
  1082.             }
  1083.             if ($container->fileExists($file $configDir.'/validation.xml'false)) {
  1084.                 $fileRecorder('xml'$file);
  1085.             }
  1086.             if ($container->fileExists($dir $configDir.'/validation''/^$/')) {
  1087.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1088.             }
  1089.         }
  1090.         $projectDir $container->getParameter('kernel.project_dir');
  1091.         if ($container->fileExists($dir $projectDir.'/config/validator''/^$/')) {
  1092.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1093.         }
  1094.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1095.     }
  1096.     private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
  1097.     {
  1098.         foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
  1099.             $fileRecorder($file->getExtension(), $file->getRealPath());
  1100.         }
  1101.     }
  1102.     private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder)
  1103.     {
  1104.         foreach ($config['mapping']['paths'] as $path) {
  1105.             if (is_dir($path)) {
  1106.                 $this->registerMappingFilesFromDir($path$fileRecorder);
  1107.                 $container->addResource(new DirectoryResource($path'/^$/'));
  1108.             } elseif ($container->fileExists($pathfalse)) {
  1109.                 if (!preg_match('/\.(xml|ya?ml)$/'$path$matches)) {
  1110.                     throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.'$path));
  1111.                 }
  1112.                 $fileRecorder($matches[1], $path);
  1113.             } else {
  1114.                 throw new \RuntimeException(sprintf('Could not open file or directory "%s".'$path));
  1115.             }
  1116.         }
  1117.     }
  1118.     private function registerAnnotationsConfiguration(array $configContainerBuilder $containerLoaderInterface $loader)
  1119.     {
  1120.         if (!$this->annotationsConfigEnabled) {
  1121.             return;
  1122.         }
  1123.         if (!class_exists('Doctrine\Common\Annotations\Annotation')) {
  1124.             throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
  1125.         }
  1126.         $loader->load('annotations.xml');
  1127.         if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  1128.             $container->getDefinition('annotations.dummy_registry')
  1129.                 ->setMethodCalls([['registerLoader', ['class_exists']]]);
  1130.         }
  1131.         if ('none' !== $config['cache']) {
  1132.             if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {
  1133.                 throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
  1134.             }
  1135.             $cacheService $config['cache'];
  1136.             if ('php_array' === $config['cache']) {
  1137.                 $cacheService 'annotations.cache';
  1138.                 // Enable warmer only if PHP array is used for cache
  1139.                 $definition $container->findDefinition('annotations.cache_warmer');
  1140.                 $definition->addTag('kernel.cache_warmer');
  1141.             } elseif ('file' === $config['cache']) {
  1142.                 $cacheDir $container->getParameterBag()->resolveValue($config['file_cache_dir']);
  1143.                 if (!is_dir($cacheDir) && false === @mkdir($cacheDir0777true) && !is_dir($cacheDir)) {
  1144.                     throw new \RuntimeException(sprintf('Could not create cache directory "%s".'$cacheDir));
  1145.                 }
  1146.                 $container
  1147.                     ->getDefinition('annotations.filesystem_cache')
  1148.                     ->replaceArgument(0$cacheDir)
  1149.                 ;
  1150.                 $cacheService 'annotations.filesystem_cache';
  1151.             }
  1152.             $container
  1153.                 ->getDefinition('annotations.cached_reader')
  1154.                 ->replaceArgument(2$config['debug'])
  1155.                 // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
  1156.                 ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
  1157.                 ->addTag('annotations.cached_reader')
  1158.             ;
  1159.             $container->setAlias('annotation_reader''annotations.cached_reader')->setPrivate(true);
  1160.             $container->setAlias(Reader::class, new Alias('annotations.cached_reader'false));
  1161.         } else {
  1162.             $container->removeDefinition('annotations.cached_reader');
  1163.         }
  1164.     }
  1165.     private function registerPropertyAccessConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1166.     {
  1167.         if (!class_exists(PropertyAccessor::class)) {
  1168.             return;
  1169.         }
  1170.         $loader->load('property_access.xml');
  1171.         $container
  1172.             ->getDefinition('property_accessor')
  1173.             ->replaceArgument(0$config['magic_call'])
  1174.             ->replaceArgument(1$config['throw_exception_on_invalid_index'])
  1175.             ->replaceArgument(3$config['throw_exception_on_invalid_property_path'])
  1176.             ->replaceArgument(4, new Reference(PropertyReadInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1177.             ->replaceArgument(5, new Reference(PropertyWriteInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1178.         ;
  1179.     }
  1180.     private function registerSecretsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1181.     {
  1182.         if (!$this->isConfigEnabled($container$config)) {
  1183.             $container->removeDefinition('console.command.secrets_set');
  1184.             $container->removeDefinition('console.command.secrets_list');
  1185.             $container->removeDefinition('console.command.secrets_remove');
  1186.             $container->removeDefinition('console.command.secrets_generate_key');
  1187.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1188.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1189.             return;
  1190.         }
  1191.         $loader->load('secrets.xml');
  1192.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1193.         if ($config['local_dotenv_file']) {
  1194.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1195.         } else {
  1196.             $container->removeDefinition('secrets.local_vault');
  1197.         }
  1198.         if ($config['decryption_env_var']) {
  1199.             if (!preg_match('/^(?:[-.\w]*+:)*+\w++$/'$config['decryption_env_var'])) {
  1200.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1201.             }
  1202.             if (class_exists(LazyString::class)) {
  1203.                 $container->getDefinition('secrets.decryption_key')->replaceArgument(1$config['decryption_env_var']);
  1204.             } else {
  1205.                 $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1206.                 $container->removeDefinition('secrets.decryption_key');
  1207.             }
  1208.         } else {
  1209.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1210.             $container->removeDefinition('secrets.decryption_key');
  1211.         }
  1212.     }
  1213.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1214.     {
  1215.         if (!$this->isConfigEnabled($container$config)) {
  1216.             return;
  1217.         }
  1218.         if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) {
  1219.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1220.         }
  1221.         if (!$this->sessionConfigEnabled) {
  1222.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1223.         }
  1224.         // Enable services for CSRF protection (even without forms)
  1225.         $loader->load('security_csrf.xml');
  1226.         if (!class_exists(CsrfExtension::class)) {
  1227.             $container->removeDefinition('twig.extension.security_csrf');
  1228.         }
  1229.     }
  1230.     private function registerSerializerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1231.     {
  1232.         $loader->load('serializer.xml');
  1233.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1234.         if (!class_exists(PropertyAccessor::class)) {
  1235.             $container->removeAlias('serializer.property_accessor');
  1236.             $container->removeDefinition('serializer.normalizer.object');
  1237.         }
  1238.         if (!class_exists(Yaml::class)) {
  1239.             $container->removeDefinition('serializer.encoder.yaml');
  1240.         }
  1241.         if (!class_exists(UnwrappingDenormalizer::class) || !class_exists(PropertyAccessor::class)) {
  1242.             $container->removeDefinition('serializer.denormalizer.unwrapping');
  1243.         }
  1244.         $serializerLoaders = [];
  1245.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1246.             if (!$this->annotationsConfigEnabled) {
  1247.                 throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
  1248.             }
  1249.             $annotationLoader = new Definition(
  1250.                 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
  1251.                 [new Reference('annotation_reader')]
  1252.             );
  1253.             $annotationLoader->setPublic(false);
  1254.             $serializerLoaders[] = $annotationLoader;
  1255.         }
  1256.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1257.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
  1258.             $definition->setPublic(false);
  1259.             $serializerLoaders[] = $definition;
  1260.         };
  1261.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1262.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1263.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1264.                 $fileRecorder('xml'$file);
  1265.             }
  1266.             if (
  1267.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1268.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1269.             ) {
  1270.                 $fileRecorder('yml'$file);
  1271.             }
  1272.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1273.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1274.             }
  1275.         }
  1276.         $projectDir $container->getParameter('kernel.project_dir');
  1277.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1278.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1279.         }
  1280.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1281.         $chainLoader->replaceArgument(0$serializerLoaders);
  1282.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1283.         if (isset($config['name_converter']) && $config['name_converter']) {
  1284.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1285.         }
  1286.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1287.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1288.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1289.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1290.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1291.         }
  1292.         if ($config['max_depth_handler'] ?? false) {
  1293.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1294.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1295.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1296.         }
  1297.     }
  1298.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerXmlFileLoader $loader)
  1299.     {
  1300.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1301.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1302.         }
  1303.         $loader->load('property_info.xml');
  1304.         if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) {
  1305.             $definition $container->register('property_info.php_doc_extractor''Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
  1306.             $definition->setPrivate(true);
  1307.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1308.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1309.         }
  1310.         if ($container->getParameter('kernel.debug')) {
  1311.             $container->removeDefinition('property_info.cache');
  1312.         }
  1313.     }
  1314.     private function registerLockConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1315.     {
  1316.         $loader->load('lock.xml');
  1317.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1318.             if (=== \count($resourceStores)) {
  1319.                 continue;
  1320.             }
  1321.             // Generate stores
  1322.             $storeDefinitions = [];
  1323.             foreach ($resourceStores as $storeDsn) {
  1324.                 $storeDsn $container->resolveEnvPlaceholders($storeDsnnull$usedEnvs);
  1325.                 $storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class);
  1326.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1327.                 $storeDefinition->setArguments([$storeDsn]);
  1328.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1329.                 $storeDefinition = new Reference($storeDefinitionId);
  1330.                 $storeDefinitions[] = $storeDefinition;
  1331.             }
  1332.             // Wrap array of stores with CombinedStore
  1333.             if (\count($storeDefinitions) > 1) {
  1334.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1335.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1336.                 $container->setDefinition('lock.'.$resourceName.'.store'$combinedDefinition);
  1337.             } else {
  1338.                 $container->setAlias('lock.'.$resourceName.'.store', new Alias((string) $storeDefinitions[0], false));
  1339.             }
  1340.             // Generate factories for each resource
  1341.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1342.             $factoryDefinition->replaceArgument(0, new Reference('lock.'.$resourceName.'.store'));
  1343.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1344.             // Generate services for lock instances
  1345.             $lockDefinition = new Definition(Lock::class);
  1346.             $lockDefinition->setPublic(false);
  1347.             $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
  1348.             $lockDefinition->setArguments([$resourceName]);
  1349.             $container->setDefinition('lock.'.$resourceName$lockDefinition);
  1350.             // provide alias for default resource
  1351.             if ('default' === $resourceName) {
  1352.                 $container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store'false));
  1353.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1354.                 $container->setAlias('lock', new Alias('lock.'.$resourceNamefalse));
  1355.                 $container->setAlias(PersistingStoreInterface::class, new Alias('lock.store'false));
  1356.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1357.                 $container->setAlias(LockInterface::class, new Alias('lock'false));
  1358.             } else {
  1359.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'PersistingStoreInterface::class, $resourceName.'.lock.store');
  1360.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1361.                 $container->registerAliasForArgument('lock.'.$resourceNameLockInterface::class, $resourceName.'.lock');
  1362.             }
  1363.         }
  1364.     }
  1365.     private function registerMessengerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $validationConfig)
  1366.     {
  1367.         if (!interface_exists(MessageBusInterface::class)) {
  1368.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1369.         }
  1370.         $loader->load('messenger.xml');
  1371.         if (class_exists(AmqpTransportFactory::class)) {
  1372.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1373.         }
  1374.         if (class_exists(RedisTransportFactory::class)) {
  1375.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1376.         }
  1377.         if (class_exists(AmazonSqsTransportFactory::class)) {
  1378.             $container->getDefinition('messenger.transport.sqs.factory')->addTag('messenger.transport_factory');
  1379.         }
  1380.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1381.             $config['default_bus'] = key($config['buses']);
  1382.         }
  1383.         $defaultMiddleware = [
  1384.             'before' => [
  1385.                 ['id' => 'add_bus_name_stamp_middleware'],
  1386.                 ['id' => 'reject_redelivered_message_middleware'],
  1387.                 ['id' => 'dispatch_after_current_bus'],
  1388.                 ['id' => 'failed_message_processing_middleware'],
  1389.             ],
  1390.             'after' => [
  1391.                 ['id' => 'send_message'],
  1392.                 ['id' => 'handle_message'],
  1393.             ],
  1394.         ];
  1395.         foreach ($config['buses'] as $busId => $bus) {
  1396.             $middleware $bus['middleware'];
  1397.             if ($bus['default_middleware']) {
  1398.                 if ('allow_no_handlers' === $bus['default_middleware']) {
  1399.                     $defaultMiddleware['after'][1]['arguments'] = [true];
  1400.                 } else {
  1401.                     unset($defaultMiddleware['after'][1]['arguments']);
  1402.                 }
  1403.                 // argument to add_bus_name_stamp_middleware
  1404.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1405.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1406.             }
  1407.             foreach ($middleware as $middlewareItem) {
  1408.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1409.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1410.                 }
  1411.             }
  1412.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1413.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1414.             }
  1415.             $container->setParameter($busId.'.middleware'$middleware);
  1416.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1417.             if ($busId === $config['default_bus']) {
  1418.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1419.                 $container->setAlias(MessageBusInterface::class, $busId);
  1420.             } else {
  1421.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1422.             }
  1423.         }
  1424.         if (empty($config['transports'])) {
  1425.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1426.             $container->removeDefinition('messenger.transport.amqp.factory');
  1427.             $container->removeDefinition('messenger.transport.redis.factory');
  1428.             $container->removeDefinition('messenger.transport.sqs.factory');
  1429.         } else {
  1430.             $container->getDefinition('messenger.transport.symfony_serializer')
  1431.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1432.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1433.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1434.         }
  1435.         $senderAliases = [];
  1436.         $transportRetryReferences = [];
  1437.         foreach ($config['transports'] as $name => $transport) {
  1438.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1439.             $transportDefinition = (new Definition(TransportInterface::class))
  1440.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1441.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1442.                 ->addTag('messenger.receiver', ['alias' => $name])
  1443.             ;
  1444.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1445.             $senderAliases[$name] = $transportId;
  1446.             if (null !== $transport['retry_strategy']['service']) {
  1447.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1448.             } else {
  1449.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1450.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1451.                 $retryDefinition
  1452.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1453.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1454.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1455.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1456.                 $container->setDefinition($retryServiceId$retryDefinition);
  1457.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1458.             }
  1459.         }
  1460.         $senderReferences = [];
  1461.         // alias => service_id
  1462.         foreach ($senderAliases as $alias => $serviceId) {
  1463.             $senderReferences[$alias] = new Reference($serviceId);
  1464.         }
  1465.         // service_id => service_id
  1466.         foreach ($senderAliases as $serviceId) {
  1467.             $senderReferences[$serviceId] = new Reference($serviceId);
  1468.         }
  1469.         $messageToSendersMapping = [];
  1470.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1471.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1472.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1473.             }
  1474.             // make sure senderAliases contains all senders
  1475.             foreach ($messageConfiguration['senders'] as $sender) {
  1476.                 if (!isset($senderReferences[$sender])) {
  1477.                     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));
  1478.                 }
  1479.             }
  1480.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1481.         }
  1482.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1483.         $container->getDefinition('messenger.senders_locator')
  1484.             ->replaceArgument(0$messageToSendersMapping)
  1485.             ->replaceArgument(1$sendersServiceLocator)
  1486.         ;
  1487.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1488.             ->replaceArgument(0$sendersServiceLocator)
  1489.         ;
  1490.         $container->getDefinition('messenger.retry_strategy_locator')
  1491.             ->replaceArgument(0$transportRetryReferences);
  1492.         if ($config['failure_transport']) {
  1493.             if (!isset($senderReferences[$config['failure_transport']])) {
  1494.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1495.             }
  1496.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1497.                 ->replaceArgument(0$senderReferences[$config['failure_transport']]);
  1498.             $container->getDefinition('console.command.messenger_failed_messages_retry')
  1499.                 ->replaceArgument(0$config['failure_transport']);
  1500.             $container->getDefinition('console.command.messenger_failed_messages_show')
  1501.                 ->replaceArgument(0$config['failure_transport']);
  1502.             $container->getDefinition('console.command.messenger_failed_messages_remove')
  1503.                 ->replaceArgument(0$config['failure_transport']);
  1504.         } else {
  1505.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1506.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1507.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1508.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1509.         }
  1510.     }
  1511.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1512.     {
  1513.         if (!class_exists(DefaultMarshaller::class)) {
  1514.             $container->removeDefinition('cache.default_marshaller');
  1515.         }
  1516.         $version = new Parameter('container.build_id');
  1517.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1518.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1519.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1520.         if (isset($config['prefix_seed'])) {
  1521.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1522.         }
  1523.         if ($container->hasParameter('cache.prefix.seed')) {
  1524.             // Inline any env vars referenced in the parameter
  1525.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1526.         }
  1527.         foreach (['doctrine''psr6''redis''memcached''pdo'] as $name) {
  1528.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1529.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1530.             }
  1531.         }
  1532.         foreach (['app''system'] as $name) {
  1533.             $config['pools']['cache.'.$name] = [
  1534.                 'adapters' => [$config[$name]],
  1535.                 'public' => true,
  1536.                 'tags' => false,
  1537.             ];
  1538.         }
  1539.         foreach ($config['pools'] as $name => $pool) {
  1540.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1541.             foreach ($pool['adapters'] as $provider => $adapter) {
  1542.                 if ($config['pools'][$adapter]['tags'] ?? false) {
  1543.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1544.                 }
  1545.             }
  1546.             if (=== \count($pool['adapters'])) {
  1547.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1548.                     $pool['provider'] = $provider;
  1549.                 }
  1550.                 $definition = new ChildDefinition($adapter);
  1551.             } else {
  1552.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1553.                 $pool['reset'] = 'reset';
  1554.             }
  1555.             if ($pool['tags']) {
  1556.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1557.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1558.                 }
  1559.                 $container->register($nameTagAwareAdapter::class)
  1560.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1561.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1562.                     ->setPublic($pool['public'])
  1563.                 ;
  1564.                 $pool['name'] = $name;
  1565.                 $pool['public'] = false;
  1566.                 $name '.'.$name.'.inner';
  1567.                 if (!\in_array($pool['name'], ['cache.app''cache.system'], true)) {
  1568.                     $container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
  1569.                     $container->registerAliasForArgument($nameCacheInterface::class, $pool['name']);
  1570.                     $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name']);
  1571.                 }
  1572.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1573.                 $container->register('.'.$name.'.taggable'TagAwareAdapter::class)
  1574.                     ->addArgument(new Reference($name))
  1575.                 ;
  1576.                 $container->registerAliasForArgument('.'.$name.'.taggable'TagAwareCacheInterface::class, $name);
  1577.                 $container->registerAliasForArgument($nameCacheInterface::class);
  1578.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class);
  1579.             }
  1580.             $definition->setPublic($pool['public']);
  1581.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1582.             $definition->addTag('cache.pool'$pool);
  1583.             $container->setDefinition($name$definition);
  1584.         }
  1585.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1586.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1587.             $propertyAccessDefinition->setPublic(false);
  1588.             if (!$container->getParameter('kernel.debug')) {
  1589.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1590.                 $propertyAccessDefinition->setArguments([null0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1591.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1592.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1593.             } else {
  1594.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1595.                 $propertyAccessDefinition->setArguments([0false]);
  1596.             }
  1597.         }
  1598.     }
  1599.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $profilerConfig)
  1600.     {
  1601.         $loader->load('http_client.xml');
  1602.         $container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
  1603.         if (!$hasPsr18 interface_exists(ClientInterface::class)) {
  1604.             $container->removeDefinition('psr18.http_client');
  1605.             $container->removeAlias(ClientInterface::class);
  1606.         }
  1607.         if (!interface_exists(HttpClient::class)) {
  1608.             $container->removeDefinition(HttpClient::class);
  1609.         }
  1610.         $httpClientId $this->isConfigEnabled($container$profilerConfig) ? '.debug.http_client.inner' 'http_client';
  1611.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1612.             if ('http_client' === $name) {
  1613.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1614.             }
  1615.             $scope $scopeConfig['scope'] ?? null;
  1616.             unset($scopeConfig['scope']);
  1617.             if (null === $scope) {
  1618.                 $baseUri $scopeConfig['base_uri'];
  1619.                 unset($scopeConfig['base_uri']);
  1620.                 $container->register($nameScopingHttpClient::class)
  1621.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1622.                     ->setArguments([new Reference($httpClientId), $baseUri$scopeConfig])
  1623.                     ->addTag('http_client.client')
  1624.                 ;
  1625.             } else {
  1626.                 $container->register($nameScopingHttpClient::class)
  1627.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1628.                     ->addTag('http_client.client')
  1629.                 ;
  1630.             }
  1631.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  1632.             if ($hasPsr18) {
  1633.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  1634.                     ->replaceArgument(0, new Reference($name));
  1635.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  1636.             }
  1637.         }
  1638.     }
  1639.     private function registerMailerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1640.     {
  1641.         if (!class_exists(Mailer::class)) {
  1642.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  1643.         }
  1644.         $loader->load('mailer.xml');
  1645.         $loader->load('mailer_transports.xml');
  1646.         if (!\count($config['transports']) && null === $config['dsn']) {
  1647.             $config['dsn'] = 'smtp://null';
  1648.         }
  1649.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  1650.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  1651.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  1652.         $mailer $container->getDefinition('mailer.mailer');
  1653.         if (false === $messageBus $config['message_bus']) {
  1654.             $mailer->replaceArgument(1null);
  1655.         } else {
  1656.             $mailer->replaceArgument(1$messageBus ? new Reference($messageBus) : new Reference('messenger.default_bus'ContainerInterface::NULL_ON_INVALID_REFERENCE));
  1657.         }
  1658.         $classToServices = [
  1659.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  1660.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  1661.             MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
  1662.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  1663.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  1664.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  1665.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  1666.         ];
  1667.         foreach ($classToServices as $class => $service) {
  1668.             if (!class_exists($class)) {
  1669.                 $container->removeDefinition($service);
  1670.             }
  1671.         }
  1672.         $recipients $config['envelope']['recipients'] ?? null;
  1673.         $sender $config['envelope']['sender'] ?? null;
  1674.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  1675.         $envelopeListener->setArgument(0$sender);
  1676.         $envelopeListener->setArgument(1$recipients);
  1677.     }
  1678.     private function registerNotifierConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1679.     {
  1680.         if (!class_exists(Notifier::class)) {
  1681.             throw new LogicException('Notifier support cannot be enabled as the component is not installed. Try running "composer require symfony/notifier".');
  1682.         }
  1683.         $loader->load('notifier.xml');
  1684.         $loader->load('notifier_transports.xml');
  1685.         if ($config['chatter_transports']) {
  1686.             $container->getDefinition('chatter.transports')->setArgument(0$config['chatter_transports']);
  1687.         } else {
  1688.             $container->removeDefinition('chatter');
  1689.         }
  1690.         if ($config['texter_transports']) {
  1691.             $container->getDefinition('texter.transports')->setArgument(0$config['texter_transports']);
  1692.         } else {
  1693.             $container->removeDefinition('texter');
  1694.         }
  1695.         if ($this->mailerConfigEnabled) {
  1696.             $sender $container->getDefinition('mailer.envelope_listener')->getArgument(0);
  1697.             $container->getDefinition('notifier.channel.email')->setArgument(2$sender);
  1698.         } else {
  1699.             $container->removeDefinition('notifier.channel.email');
  1700.         }
  1701.         if ($this->messengerConfigEnabled) {
  1702.             if ($config['notification_on_failed_messages']) {
  1703.                 $container->getDefinition('notifier.failed_message_listener')->addTag('kernel.event_subscriber');
  1704.             }
  1705.             // as we have a bus, the channels don't need the transports
  1706.             $container->getDefinition('notifier.channel.chat')->setArgument(0null);
  1707.             if ($container->hasDefinition('notifier.channel.email')) {
  1708.                 $container->getDefinition('notifier.channel.email')->setArgument(0null);
  1709.             }
  1710.             $container->getDefinition('notifier.channel.sms')->setArgument(0null);
  1711.         }
  1712.         $container->getDefinition('notifier.channel_policy')->setArgument(0$config['channel_policy']);
  1713.         $classToServices = [
  1714.             SlackTransportFactory::class => 'notifier.transport_factory.slack',
  1715.             TelegramTransportFactory::class => 'notifier.transport_factory.telegram',
  1716.             MattermostTransportFactory::class => 'notifier.transport_factory.mattermost',
  1717.             NexmoTransportFactory::class => 'notifier.transport_factory.nexmo',
  1718.             RocketChatTransportFactory::class => 'notifier.transport_factory.rocketchat',
  1719.             TwilioTransportFactory::class => 'notifier.transport_factory.twilio',
  1720.             FirebaseTransportFactory::class => 'notifier.transport_factory.firebase',
  1721.             FreeMobileTransportFactory::class => 'notifier.transport_factory.freemobile',
  1722.             OvhCloudTransportFactory::class => 'notifier.transport_factory.ovhcloud',
  1723.             SinchTransportFactory::class => 'notifier.transport_factory.sinch',
  1724.         ];
  1725.         foreach ($classToServices as $class => $service) {
  1726.             if (!class_exists($class)) {
  1727.                 $container->removeDefinition($service);
  1728.             }
  1729.         }
  1730.         if (isset($config['admin_recipients'])) {
  1731.             $notifier $container->getDefinition('notifier');
  1732.             foreach ($config['admin_recipients'] as $i => $recipient) {
  1733.                 $id 'notifier.admin_recipient.'.$i;
  1734.                 $container->setDefinition($id, new Definition(AdminRecipient::class, [$recipient['email'], $recipient['phone']]));
  1735.                 $notifier->addMethodCall('addAdminRecipient', [new Reference($id)]);
  1736.             }
  1737.         }
  1738.     }
  1739.     /**
  1740.      * {@inheritdoc}
  1741.      */
  1742.     public function getXsdValidationBasePath()
  1743.     {
  1744.         return \dirname(__DIR__).'/Resources/config/schema';
  1745.     }
  1746.     public function getNamespace()
  1747.     {
  1748.         return 'http://symfony.com/schema/dic/symfony';
  1749.     }
  1750. }