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

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(Translator::class) && $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')) ?: ($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::class)) {
  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::class)) {
  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::class)) {
  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::class)) {
  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.         $container->setParameter('container.behavior_describing_tags', [
  441.             'container.service_locator',
  442.             'container.service_subscriber',
  443.             'kernel.event_subscriber',
  444.             'kernel.locale_aware',
  445.             'kernel.reset',
  446.         ]);
  447.     }
  448.     /**
  449.      * {@inheritdoc}
  450.      */
  451.     public function getConfiguration(array $configContainerBuilder $container)
  452.     {
  453.         return new Configuration($container->getParameter('kernel.debug'));
  454.     }
  455.     private function registerFormConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  456.     {
  457.         $loader->load('form.xml');
  458.         if (null === $config['form']['csrf_protection']['enabled']) {
  459.             $config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
  460.         }
  461.         if ($this->isConfigEnabled($container$config['form']['csrf_protection'])) {
  462.             $loader->load('form_csrf.xml');
  463.             $container->setParameter('form.type_extension.csrf.enabled'true);
  464.             $container->setParameter('form.type_extension.csrf.field_name'$config['form']['csrf_protection']['field_name']);
  465.         } else {
  466.             $container->setParameter('form.type_extension.csrf.enabled'false);
  467.         }
  468.         if (!class_exists(Translator::class)) {
  469.             $container->removeDefinition('form.type_extension.upload.validator');
  470.         }
  471.         if (!method_exists(CachingFactoryDecorator::class, 'reset')) {
  472.             $container->getDefinition('form.choice_list_factory.cached')
  473.                 ->clearTag('kernel.reset')
  474.             ;
  475.         }
  476.     }
  477.     private function registerEsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  478.     {
  479.         if (!$this->isConfigEnabled($container$config)) {
  480.             $container->removeDefinition('fragment.renderer.esi');
  481.             return;
  482.         }
  483.         $loader->load('esi.xml');
  484.     }
  485.     private function registerSsiConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  486.     {
  487.         if (!$this->isConfigEnabled($container$config)) {
  488.             $container->removeDefinition('fragment.renderer.ssi');
  489.             return;
  490.         }
  491.         $loader->load('ssi.xml');
  492.     }
  493.     private function registerFragmentsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  494.     {
  495.         if (!$this->isConfigEnabled($container$config)) {
  496.             $container->removeDefinition('fragment.renderer.hinclude');
  497.             return;
  498.         }
  499.         $container->setParameter('fragment.renderer.hinclude.global_template'$config['hinclude_default_template']);
  500.         $loader->load('fragment_listener.xml');
  501.         $container->setParameter('fragment.path'$config['path']);
  502.     }
  503.     private function registerProfilerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  504.     {
  505.         if (!$this->isConfigEnabled($container$config)) {
  506.             // this is needed for the WebProfiler to work even if the profiler is disabled
  507.             $container->setParameter('data_collector.templates', []);
  508.             return;
  509.         }
  510.         $loader->load('profiling.xml');
  511.         $loader->load('collectors.xml');
  512.         $loader->load('cache_debug.xml');
  513.         if ($this->formConfigEnabled) {
  514.             $loader->load('form_debug.xml');
  515.         }
  516.         if ($this->validatorConfigEnabled) {
  517.             $loader->load('validator_debug.xml');
  518.         }
  519.         if ($this->translationConfigEnabled) {
  520.             $loader->load('translation_debug.xml');
  521.             $container->getDefinition('translator.data_collector')->setDecoratedService('translator');
  522.         }
  523.         if ($this->messengerConfigEnabled) {
  524.             $loader->load('messenger_debug.xml');
  525.         }
  526.         if ($this->mailerConfigEnabled) {
  527.             $loader->load('mailer_debug.xml');
  528.         }
  529.         if ($this->httpClientConfigEnabled) {
  530.             $loader->load('http_client_debug.xml');
  531.         }
  532.         $container->setParameter('profiler_listener.only_exceptions'$config['only_exceptions']);
  533.         $container->setParameter('profiler_listener.only_master_requests'$config['only_master_requests']);
  534.         // Choose storage class based on the DSN
  535.         [$class] = explode(':'$config['dsn'], 2);
  536.         if ('file' !== $class) {
  537.             throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.'$class));
  538.         }
  539.         $container->setParameter('profiler.storage.dsn'$config['dsn']);
  540.         $container->getDefinition('profiler')
  541.             ->addArgument($config['collect'])
  542.             ->addTag('kernel.reset', ['method' => 'reset']);
  543.     }
  544.     private function registerWorkflowConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  545.     {
  546.         if (!$config['enabled']) {
  547.             $container->removeDefinition('console.command.workflow_dump');
  548.             return;
  549.         }
  550.         if (!class_exists(Workflow\Workflow::class)) {
  551.             throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed. Try running "composer require symfony/workflow".');
  552.         }
  553.         $loader->load('workflow.xml');
  554.         $registryDefinition $container->getDefinition('workflow.registry');
  555.         foreach ($config['workflows'] as $name => $workflow) {
  556.             $type $workflow['type'];
  557.             $workflowId sprintf('%s.%s'$type$name);
  558.             // Process Metadata (workflow + places (transition is done in the "create transition" block))
  559.             $metadataStoreDefinition = new Definition(Workflow\Metadata\InMemoryMetadataStore::class, [[], [], null]);
  560.             if ($workflow['metadata']) {
  561.                 $metadataStoreDefinition->replaceArgument(0$workflow['metadata']);
  562.             }
  563.             $placesMetadata = [];
  564.             foreach ($workflow['places'] as $place) {
  565.                 if ($place['metadata']) {
  566.                     $placesMetadata[$place['name']] = $place['metadata'];
  567.                 }
  568.             }
  569.             if ($placesMetadata) {
  570.                 $metadataStoreDefinition->replaceArgument(1$placesMetadata);
  571.             }
  572.             // Create transitions
  573.             $transitions = [];
  574.             $guardsConfiguration = [];
  575.             $transitionsMetadataDefinition = new Definition(\SplObjectStorage::class);
  576.             // Global transition counter per workflow
  577.             $transitionCounter 0;
  578.             foreach ($workflow['transitions'] as $transition) {
  579.                 if ('workflow' === $type) {
  580.                     $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]);
  581.                     $transitionDefinition->setPublic(false);
  582.                     $transitionId sprintf('.%s.transition.%s'$workflowId$transitionCounter++);
  583.                     $container->setDefinition($transitionId$transitionDefinition);
  584.                     $transitions[] = new Reference($transitionId);
  585.                     if (isset($transition['guard'])) {
  586.                         $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  587.                         $configuration->addArgument(new Reference($transitionId));
  588.                         $configuration->addArgument($transition['guard']);
  589.                         $configuration->setPublic(false);
  590.                         $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  591.                         $guardsConfiguration[$eventName][] = $configuration;
  592.                     }
  593.                     if ($transition['metadata']) {
  594.                         $transitionsMetadataDefinition->addMethodCall('attach', [
  595.                             new Reference($transitionId),
  596.                             $transition['metadata'],
  597.                         ]);
  598.                     }
  599.                 } elseif ('state_machine' === $type) {
  600.                     foreach ($transition['from'] as $from) {
  601.                         foreach ($transition['to'] as $to) {
  602.                             $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from$to]);
  603.                             $transitionDefinition->setPublic(false);
  604.                             $transitionId sprintf('.%s.transition.%s'$workflowId$transitionCounter++);
  605.                             $container->setDefinition($transitionId$transitionDefinition);
  606.                             $transitions[] = new Reference($transitionId);
  607.                             if (isset($transition['guard'])) {
  608.                                 $configuration = new Definition(Workflow\EventListener\GuardExpression::class);
  609.                                 $configuration->addArgument(new Reference($transitionId));
  610.                                 $configuration->addArgument($transition['guard']);
  611.                                 $configuration->setPublic(false);
  612.                                 $eventName sprintf('workflow.%s.guard.%s'$name$transition['name']);
  613.                                 $guardsConfiguration[$eventName][] = $configuration;
  614.                             }
  615.                             if ($transition['metadata']) {
  616.                                 $transitionsMetadataDefinition->addMethodCall('attach', [
  617.                                     new Reference($transitionId),
  618.                                     $transition['metadata'],
  619.                                 ]);
  620.                             }
  621.                         }
  622.                     }
  623.                 }
  624.             }
  625.             $metadataStoreDefinition->replaceArgument(2$transitionsMetadataDefinition);
  626.             // Create places
  627.             $places array_column($workflow['places'], 'name');
  628.             $initialMarking $workflow['initial_marking'] ?? [];
  629.             // Create a Definition
  630.             $definitionDefinition = new Definition(Workflow\Definition::class);
  631.             $definitionDefinition->setPublic(false);
  632.             $definitionDefinition->addArgument($places);
  633.             $definitionDefinition->addArgument($transitions);
  634.             $definitionDefinition->addArgument($initialMarking);
  635.             $definitionDefinition->addArgument($metadataStoreDefinition);
  636.             $definitionDefinition->addTag('workflow.definition', [
  637.                 'name' => $name,
  638.                 'type' => $type,
  639.             ]);
  640.             // Create MarkingStore
  641.             if (isset($workflow['marking_store']['type'])) {
  642.                 $markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
  643.                 $markingStoreDefinition->setArguments([
  644.                     'state_machine' === $type//single state
  645.                     $workflow['marking_store']['property'],
  646.                 ]);
  647.             } elseif (isset($workflow['marking_store']['service'])) {
  648.                 $markingStoreDefinition = new Reference($workflow['marking_store']['service']);
  649.             }
  650.             // Create Workflow
  651.             $workflowDefinition = new ChildDefinition(sprintf('%s.abstract'$type));
  652.             $workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition'$workflowId)));
  653.             if (isset($markingStoreDefinition)) {
  654.                 $workflowDefinition->replaceArgument(1$markingStoreDefinition);
  655.             }
  656.             $workflowDefinition->replaceArgument(3$name);
  657.             // Store to container
  658.             $container->setDefinition($workflowId$workflowDefinition);
  659.             $container->setDefinition(sprintf('%s.definition'$workflowId), $definitionDefinition);
  660.             $container->registerAliasForArgument($workflowIdWorkflowInterface::class, $name.'.'.$type);
  661.             // Validate Workflow
  662.             if ('state_machine' === $workflow['type']) {
  663.                 $validator = new Workflow\Validator\StateMachineValidator();
  664.             } else {
  665.                 $validator = new Workflow\Validator\WorkflowValidator();
  666.             }
  667.             $trs array_map(function (Reference $ref) use ($container): Workflow\Transition {
  668.                 return $container->get((string) $ref);
  669.             }, $transitions);
  670.             $realDefinition = new Workflow\Definition($places$trs$initialMarking);
  671.             $validator->validate($realDefinition$name);
  672.             // Add workflow to Registry
  673.             if ($workflow['supports']) {
  674.                 foreach ($workflow['supports'] as $supportedClassName) {
  675.                     $strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, [$supportedClassName]);
  676.                     $strategyDefinition->setPublic(false);
  677.                     $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
  678.                 }
  679.             } elseif (isset($workflow['support_strategy'])) {
  680.                 $registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), new Reference($workflow['support_strategy'])]);
  681.             }
  682.             // Enable the AuditTrail
  683.             if ($workflow['audit_trail']['enabled']) {
  684.                 $listener = new Definition(Workflow\EventListener\AuditTrailListener::class);
  685.                 $listener->setPrivate(true);
  686.                 $listener->addTag('monolog.logger', ['channel' => 'workflow']);
  687.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave'$name), 'method' => 'onLeave']);
  688.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition'$name), 'method' => 'onTransition']);
  689.                 $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter'$name), 'method' => 'onEnter']);
  690.                 $listener->addArgument(new Reference('logger'));
  691.                 $container->setDefinition(sprintf('.%s.listener.audit_trail'$workflowId), $listener);
  692.             }
  693.             // Add Guard Listener
  694.             if ($guardsConfiguration) {
  695.                 if (!class_exists(ExpressionLanguage::class)) {
  696.                     throw new LogicException('Cannot guard workflows as the ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
  697.                 }
  698.                 if (!class_exists(Security::class)) {
  699.                     throw new LogicException('Cannot guard workflows as the Security component is not installed. Try running "composer require symfony/security-core".');
  700.                 }
  701.                 $guard = new Definition(Workflow\EventListener\GuardListener::class);
  702.                 $guard->setPrivate(true);
  703.                 $guard->setArguments([
  704.                     $guardsConfiguration,
  705.                     new Reference('workflow.security.expression_language'),
  706.                     new Reference('security.token_storage'),
  707.                     new Reference('security.authorization_checker'),
  708.                     new Reference('security.authentication.trust_resolver'),
  709.                     new Reference('security.role_hierarchy'),
  710.                     new Reference('validator'ContainerInterface::NULL_ON_INVALID_REFERENCE),
  711.                 ]);
  712.                 foreach ($guardsConfiguration as $eventName => $config) {
  713.                     $guard->addTag('kernel.event_listener', ['event' => $eventName'method' => 'onTransition']);
  714.                 }
  715.                 $container->setDefinition(sprintf('.%s.listener.guard'$workflowId), $guard);
  716.                 $container->setParameter('workflow.has_guard_listeners'true);
  717.             }
  718.         }
  719.     }
  720.     private function registerDebugConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  721.     {
  722.         $loader->load('debug_prod.xml');
  723.         if (class_exists(Stopwatch::class)) {
  724.             $container->register('debug.stopwatch'Stopwatch::class)
  725.                 ->addArgument(true)
  726.                 ->setPrivate(true)
  727.                 ->addTag('kernel.reset', ['method' => 'reset']);
  728.             $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch'false));
  729.         }
  730.         $debug $container->getParameter('kernel.debug');
  731.         if ($debug) {
  732.             $container->setParameter('debug.container.dump''%kernel.cache_dir%/%kernel.container_class%.xml');
  733.         }
  734.         if ($debug && class_exists(Stopwatch::class)) {
  735.             $loader->load('debug.xml');
  736.         }
  737.         $definition $container->findDefinition('debug.debug_handlers_listener');
  738.         if (false === $config['log']) {
  739.             $definition->replaceArgument(1null);
  740.         } elseif (true !== $config['log']) {
  741.             $definition->replaceArgument(2$config['log']);
  742.         }
  743.         if (!$config['throw']) {
  744.             $container->setParameter('debug.error_handler.throw_at'0);
  745.         }
  746.         if ($debug && class_exists(DebugProcessor::class)) {
  747.             $definition = new Definition(DebugProcessor::class);
  748.             $definition->setPublic(false);
  749.             $definition->addArgument(new Reference('request_stack'));
  750.             $container->setDefinition('debug.log_processor'$definition);
  751.         }
  752.     }
  753.     private function registerRouterConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $enabledLocales = [])
  754.     {
  755.         if (!$this->isConfigEnabled($container$config)) {
  756.             $container->removeDefinition('console.command.router_debug');
  757.             $container->removeDefinition('console.command.router_match');
  758.             return;
  759.         }
  760.         $loader->load('routing.xml');
  761.         if (null === $config['utf8']) {
  762.             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.');
  763.         }
  764.         if ($config['utf8']) {
  765.             $container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
  766.         }
  767.         if ($enabledLocales) {
  768.             $enabledLocales implode('|'array_map('preg_quote'$enabledLocales));
  769.             $container->getDefinition('routing.loader')->replaceArgument(2, ['_locale' => $enabledLocales]);
  770.         }
  771.         if (!class_exists(ExpressionLanguage::class)) {
  772.             $container->removeDefinition('router.expression_language_provider');
  773.         }
  774.         $container->setParameter('router.resource'$config['resource']);
  775.         $router $container->findDefinition('router.default');
  776.         $argument $router->getArgument(2);
  777.         $argument['strict_requirements'] = $config['strict_requirements'];
  778.         if (isset($config['type'])) {
  779.             $argument['resource_type'] = $config['type'];
  780.         }
  781.         $router->replaceArgument(2$argument);
  782.         $container->setParameter('request_listener.http_port'$config['http_port']);
  783.         $container->setParameter('request_listener.https_port'$config['https_port']);
  784.         if (null !== $config['default_uri']) {
  785.             $container->getDefinition('router.request_context')
  786.                 ->replaceArgument(0$config['default_uri']);
  787.         }
  788.         if ($this->annotationsConfigEnabled) {
  789.             $container->register('routing.loader.annotation'AnnotatedRouteControllerLoader::class)
  790.                 ->setPublic(false)
  791.                 ->addTag('routing.loader', ['priority' => -10])
  792.                 ->addArgument(new Reference('annotation_reader'));
  793.             $container->register('routing.loader.annotation.directory'AnnotationDirectoryLoader::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.             $container->register('routing.loader.annotation.file'AnnotationFileLoader::class)
  801.                 ->setPublic(false)
  802.                 ->addTag('routing.loader', ['priority' => -10])
  803.                 ->setArguments([
  804.                     new Reference('file_locator'),
  805.                     new Reference('routing.loader.annotation'),
  806.                 ]);
  807.         }
  808.     }
  809.     private function registerSessionConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  810.     {
  811.         $loader->load('session.xml');
  812.         // session storage
  813.         $container->setAlias('session.storage'$config['storage_id'])->setPrivate(true);
  814.         $options = ['cache_limiter' => '0'];
  815.         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) {
  816.             if (isset($config[$key])) {
  817.                 $options[$key] = $config[$key];
  818.             }
  819.         }
  820.         if ('auto' === ($options['cookie_secure'] ?? null)) {
  821.             $locator $container->getDefinition('session_listener')->getArgument(0);
  822.             $locator->setValues($locator->getValues() + [
  823.                 'session_storage' => new Reference('session.storage'ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
  824.                 'request_stack' => new Reference('request_stack'),
  825.             ]);
  826.         }
  827.         $container->setParameter('session.storage.options'$options);
  828.         // session handler (the internal callback registered with PHP session management)
  829.         if (null === $config['handler_id']) {
  830.             // Set the handler class to be null
  831.             $container->getDefinition('session.storage.native')->replaceArgument(1null);
  832.             $container->getDefinition('session.storage.php_bridge')->replaceArgument(0null);
  833.             $container->setAlias('session.handler''session.handler.native_file')->setPrivate(true);
  834.         } else {
  835.             $container->resolveEnvPlaceholders($config['handler_id'], null$usedEnvs);
  836.             if ($usedEnvs || preg_match('#^[a-z]++://#'$config['handler_id'])) {
  837.                 $id '.cache_connection.'.ContainerBuilder::hash($config['handler_id']);
  838.                 $container->getDefinition('session.abstract_handler')
  839.                     ->replaceArgument(0$container->hasDefinition($id) ? new Reference($id) : $config['handler_id']);
  840.                 $container->setAlias('session.handler''session.abstract_handler')->setPrivate(true);
  841.             } else {
  842.                 $container->setAlias('session.handler'$config['handler_id'])->setPrivate(true);
  843.             }
  844.         }
  845.         $container->setParameter('session.save_path'$config['save_path']);
  846.         $container->setParameter('session.metadata.update_threshold'$config['metadata_update_threshold']);
  847.     }
  848.     private function registerRequestConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  849.     {
  850.         if ($config['formats']) {
  851.             $loader->load('request.xml');
  852.             $listener $container->getDefinition('request.add_request_formats_listener');
  853.             $listener->replaceArgument(0$config['formats']);
  854.         }
  855.     }
  856.     private function registerAssetsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  857.     {
  858.         $loader->load('assets.xml');
  859.         if ($config['version_strategy']) {
  860.             $defaultVersion = new Reference($config['version_strategy']);
  861.         } else {
  862.             $defaultVersion $this->createVersion($container$config['version'], $config['version_format'], $config['json_manifest_path'], '_default');
  863.         }
  864.         $defaultPackage $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
  865.         $container->setDefinition('assets._default_package'$defaultPackage);
  866.         $namedPackages = [];
  867.         foreach ($config['packages'] as $name => $package) {
  868.             if (null !== $package['version_strategy']) {
  869.                 $version = new Reference($package['version_strategy']);
  870.             } elseif (!\array_key_exists('version'$package) && null === $package['json_manifest_path']) {
  871.                 // if neither version nor json_manifest_path are specified, use the default
  872.                 $version $defaultVersion;
  873.             } else {
  874.                 // let format fallback to main version_format
  875.                 $format $package['version_format'] ?: $config['version_format'];
  876.                 $version $package['version'] ?? null;
  877.                 $version $this->createVersion($container$version$format$package['json_manifest_path'], $name);
  878.             }
  879.             $container->setDefinition('assets._package_'.$name$this->createPackageDefinition($package['base_path'], $package['base_urls'], $version));
  880.             $container->registerAliasForArgument('assets._package_'.$namePackageInterface::class, $name.'.package');
  881.             $namedPackages[$name] = new Reference('assets._package_'.$name);
  882.         }
  883.         $container->getDefinition('assets.packages')
  884.             ->replaceArgument(0, new Reference('assets._default_package'))
  885.             ->replaceArgument(1$namedPackages)
  886.         ;
  887.     }
  888.     /**
  889.      * Returns a definition for an asset package.
  890.      */
  891.     private function createPackageDefinition(?string $basePath, array $baseUrlsReference $version): Definition
  892.     {
  893.         if ($basePath && $baseUrls) {
  894.             throw new \LogicException('An asset package cannot have base URLs and base paths.');
  895.         }
  896.         $package = new ChildDefinition($baseUrls 'assets.url_package' 'assets.path_package');
  897.         $package
  898.             ->setPublic(false)
  899.             ->replaceArgument(0$baseUrls ?: $basePath)
  900.             ->replaceArgument(1$version)
  901.         ;
  902.         return $package;
  903.     }
  904.     private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPathstring $name): Reference
  905.     {
  906.         // Configuration prevents $version and $jsonManifestPath from being set
  907.         if (null !== $version) {
  908.             $def = new ChildDefinition('assets.static_version_strategy');
  909.             $def
  910.                 ->replaceArgument(0$version)
  911.                 ->replaceArgument(1$format)
  912.             ;
  913.             $container->setDefinition('assets._version_'.$name$def);
  914.             return new Reference('assets._version_'.$name);
  915.         }
  916.         if (null !== $jsonManifestPath) {
  917.             $definitionName 'assets.json_manifest_version_strategy';
  918.             if (=== strpos(parse_url($jsonManifestPath, \PHP_URL_SCHEME), 'http')) {
  919.                 $definitionName 'assets.remote_json_manifest_version_strategy';
  920.             }
  921.             $def = new ChildDefinition($definitionName);
  922.             $def->replaceArgument(0$jsonManifestPath);
  923.             $container->setDefinition('assets._version_'.$name$def);
  924.             return new Reference('assets._version_'.$name);
  925.         }
  926.         return new Reference('assets.empty_version_strategy');
  927.     }
  928.     private function registerTranslatorConfiguration(array $configContainerBuilder $containerLoaderInterface $loaderstring $defaultLocale)
  929.     {
  930.         if (!$this->isConfigEnabled($container$config)) {
  931.             $container->removeDefinition('console.command.translation_debug');
  932.             $container->removeDefinition('console.command.translation_update');
  933.             return;
  934.         }
  935.         $loader->load('translation.xml');
  936.         // Use the "real" translator instead of the identity default
  937.         $container->setAlias('translator''translator.default')->setPublic(true);
  938.         $container->setAlias('translator.formatter', new Alias($config['formatter'], false));
  939.         $translator $container->findDefinition('translator.default');
  940.         $translator->addMethodCall('setFallbackLocales', [$config['fallbacks'] ?: [$defaultLocale]]);
  941.         $defaultOptions $translator->getArgument(4);
  942.         $defaultOptions['cache_dir'] = $config['cache_dir'];
  943.         $translator->setArgument(4$defaultOptions);
  944.         $translator->setArgument(5$config['enabled_locales']);
  945.         $container->setParameter('translator.logging'$config['logging']);
  946.         $container->setParameter('translator.default_path'$config['default_path']);
  947.         // Discover translation directories
  948.         $dirs = [];
  949.         $transPaths = [];
  950.         $nonExistingDirs = [];
  951.         if (class_exists(\Symfony\Component\Validator\Validation::class)) {
  952.             $r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
  953.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  954.         }
  955.         if (class_exists(\Symfony\Component\Form\Form::class)) {
  956.             $r = new \ReflectionClass(\Symfony\Component\Form\Form::class);
  957.             $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
  958.         }
  959.         if (class_exists(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) {
  960.             $r = new \ReflectionClass(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
  961.             $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
  962.         }
  963.         $defaultDir $container->getParameterBag()->resolveValue($config['default_path']);
  964.         foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
  965.             if ($container->fileExists($dir $bundle['path'].'/Resources/translations') || $container->fileExists($dir $bundle['path'].'/translations')) {
  966.                 $dirs[] = $dir;
  967.             } else {
  968.                 $nonExistingDirs[] = $dir;
  969.             }
  970.         }
  971.         foreach ($config['paths'] as $dir) {
  972.             if ($container->fileExists($dir)) {
  973.                 $dirs[] = $transPaths[] = $dir;
  974.             } else {
  975.                 throw new \UnexpectedValueException(sprintf('"%s" defined in translator.paths does not exist or is not a directory.'$dir));
  976.             }
  977.         }
  978.         if ($container->hasDefinition('console.command.translation_debug')) {
  979.             $container->getDefinition('console.command.translation_debug')->replaceArgument(5$transPaths);
  980.         }
  981.         if ($container->hasDefinition('console.command.translation_update')) {
  982.             $container->getDefinition('console.command.translation_update')->replaceArgument(6$transPaths);
  983.         }
  984.         if ($container->fileExists($defaultDir)) {
  985.             $dirs[] = $defaultDir;
  986.         } else {
  987.             $nonExistingDirs[] = $defaultDir;
  988.         }
  989.         // Register translation resources
  990.         if ($dirs) {
  991.             $files = [];
  992.             $finder Finder::create()
  993.                 ->followLinks()
  994.                 ->files()
  995.                 ->filter(function (\SplFileInfo $file) {
  996.                     return <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/'$file->getBasename());
  997.                 })
  998.                 ->in($dirs)
  999.                 ->sortByName()
  1000.             ;
  1001.             foreach ($finder as $file) {
  1002.                 $fileNameParts explode('.'basename($file));
  1003.                 $locale $fileNameParts[\count($fileNameParts) - 2];
  1004.                 if (!isset($files[$locale])) {
  1005.                     $files[$locale] = [];
  1006.                 }
  1007.                 $files[$locale][] = (string) $file;
  1008.             }
  1009.             $projectDir $container->getParameter('kernel.project_dir');
  1010.             $options array_merge(
  1011.                 $translator->getArgument(4),
  1012.                 [
  1013.                     'resource_files' => $files,
  1014.                     'scanned_directories' => $scannedDirectories array_merge($dirs$nonExistingDirs),
  1015.                     'cache_vary' => [
  1016.                         'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
  1017.                             return === strpos($dir$projectDir.'/') ? substr($dir+ \strlen($projectDir)) : $dir;
  1018.                         }, $scannedDirectories),
  1019.                     ],
  1020.                 ]
  1021.             );
  1022.             $translator->replaceArgument(4$options);
  1023.         }
  1024.     }
  1025.     private function registerValidationConfiguration(array $configContainerBuilder $containerXmlFileLoader $loaderbool $propertyInfoEnabled)
  1026.     {
  1027.         if (!$this->validatorConfigEnabled $this->isConfigEnabled($container$config)) {
  1028.             return;
  1029.         }
  1030.         if (!class_exists(\Symfony\Component\Validator\Validation::class)) {
  1031.             throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
  1032.         }
  1033.         if (!isset($config['email_validation_mode'])) {
  1034.             $config['email_validation_mode'] = 'loose';
  1035.         }
  1036.         $loader->load('validator.xml');
  1037.         $validatorBuilder $container->getDefinition('validator.builder');
  1038.         $container->setParameter('validator.translation_domain'$config['translation_domain']);
  1039.         $files = ['xml' => [], 'yml' => []];
  1040.         $this->registerValidatorMapping($container$config$files);
  1041.         if (!empty($files['xml'])) {
  1042.             $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
  1043.         }
  1044.         if (!empty($files['yml'])) {
  1045.             $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
  1046.         }
  1047.         $definition $container->findDefinition('validator.email');
  1048.         $definition->replaceArgument(0$config['email_validation_mode']);
  1049.         if (\array_key_exists('enable_annotations'$config) && $config['enable_annotations']) {
  1050.             if (!$this->annotationsConfigEnabled) {
  1051.                 throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
  1052.             }
  1053.             $validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
  1054.         }
  1055.         if (\array_key_exists('static_method'$config) && $config['static_method']) {
  1056.             foreach ($config['static_method'] as $methodName) {
  1057.                 $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
  1058.             }
  1059.         }
  1060.         if (!$container->getParameter('kernel.debug')) {
  1061.             $validatorBuilder->addMethodCall('setMappingCache', [new Reference('validator.mapping.cache.adapter')]);
  1062.         }
  1063.         $container->setParameter('validator.auto_mapping'$config['auto_mapping']);
  1064.         if (!$propertyInfoEnabled || !class_exists(PropertyInfoLoader::class)) {
  1065.             $container->removeDefinition('validator.property_info_loader');
  1066.         }
  1067.         $container
  1068.             ->getDefinition('validator.not_compromised_password')
  1069.             ->setArgument(2$config['not_compromised_password']['enabled'])
  1070.             ->setArgument(3$config['not_compromised_password']['endpoint'])
  1071.         ;
  1072.     }
  1073.     private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files)
  1074.     {
  1075.         $fileRecorder = function ($extension$path) use (&$files) {
  1076.             $files['yaml' === $extension 'yml' $extension][] = $path;
  1077.         };
  1078.         if (interface_exists(\Symfony\Component\Form\FormInterface::class)) {
  1079.             $reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class);
  1080.             $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
  1081.         }
  1082.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1083.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1084.             if (
  1085.                 $container->fileExists($file $configDir.'/validation.yaml'false) ||
  1086.                 $container->fileExists($file $configDir.'/validation.yml'false)
  1087.             ) {
  1088.                 $fileRecorder('yml'$file);
  1089.             }
  1090.             if ($container->fileExists($file $configDir.'/validation.xml'false)) {
  1091.                 $fileRecorder('xml'$file);
  1092.             }
  1093.             if ($container->fileExists($dir $configDir.'/validation''/^$/')) {
  1094.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1095.             }
  1096.         }
  1097.         $projectDir $container->getParameter('kernel.project_dir');
  1098.         if ($container->fileExists($dir $projectDir.'/config/validator''/^$/')) {
  1099.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1100.         }
  1101.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1102.     }
  1103.     private function registerMappingFilesFromDir(string $dir, callable $fileRecorder)
  1104.     {
  1105.         foreach (Finder::create()->followLinks()->files()->in($dir)->name('/\.(xml|ya?ml)$/')->sortByName() as $file) {
  1106.             $fileRecorder($file->getExtension(), $file->getRealPath());
  1107.         }
  1108.     }
  1109.     private function registerMappingFilesFromConfig(ContainerBuilder $container, array $config, callable $fileRecorder)
  1110.     {
  1111.         foreach ($config['mapping']['paths'] as $path) {
  1112.             if (is_dir($path)) {
  1113.                 $this->registerMappingFilesFromDir($path$fileRecorder);
  1114.                 $container->addResource(new DirectoryResource($path'/^$/'));
  1115.             } elseif ($container->fileExists($pathfalse)) {
  1116.                 if (!preg_match('/\.(xml|ya?ml)$/'$path$matches)) {
  1117.                     throw new \RuntimeException(sprintf('Unsupported mapping type in "%s", supported types are XML & Yaml.'$path));
  1118.                 }
  1119.                 $fileRecorder($matches[1], $path);
  1120.             } else {
  1121.                 throw new \RuntimeException(sprintf('Could not open file or directory "%s".'$path));
  1122.             }
  1123.         }
  1124.     }
  1125.     private function registerAnnotationsConfiguration(array $configContainerBuilder $containerLoaderInterface $loader)
  1126.     {
  1127.         if (!$this->annotationsConfigEnabled) {
  1128.             return;
  1129.         }
  1130.         if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
  1131.             throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
  1132.         }
  1133.         $loader->load('annotations.xml');
  1134.         if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  1135.             $container->getDefinition('annotations.dummy_registry')
  1136.                 ->setMethodCalls([['registerLoader', ['class_exists']]]);
  1137.         }
  1138.         if ('none' !== $config['cache']) {
  1139.             if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
  1140.                 throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
  1141.             }
  1142.             $cacheService $config['cache'];
  1143.             if ('php_array' === $config['cache']) {
  1144.                 $cacheService 'annotations.cache';
  1145.                 // Enable warmer only if PHP array is used for cache
  1146.                 $definition $container->findDefinition('annotations.cache_warmer');
  1147.                 $definition->addTag('kernel.cache_warmer');
  1148.             } elseif ('file' === $config['cache']) {
  1149.                 $cacheDir $container->getParameterBag()->resolveValue($config['file_cache_dir']);
  1150.                 if (!is_dir($cacheDir) && false === @mkdir($cacheDir0777true) && !is_dir($cacheDir)) {
  1151.                     throw new \RuntimeException(sprintf('Could not create cache directory "%s".'$cacheDir));
  1152.                 }
  1153.                 $container
  1154.                     ->getDefinition('annotations.filesystem_cache')
  1155.                     ->replaceArgument(0$cacheDir)
  1156.                 ;
  1157.                 $cacheService 'annotations.filesystem_cache';
  1158.             }
  1159.             $container
  1160.                 ->getDefinition('annotations.cached_reader')
  1161.                 ->replaceArgument(2$config['debug'])
  1162.                 // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
  1163.                 ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
  1164.                 ->addTag('annotations.cached_reader')
  1165.             ;
  1166.             $container->setAlias('annotation_reader''annotations.cached_reader')->setPrivate(true);
  1167.             $container->setAlias(Reader::class, new Alias('annotations.cached_reader'false));
  1168.         } else {
  1169.             $container->removeDefinition('annotations.cached_reader');
  1170.         }
  1171.     }
  1172.     private function registerPropertyAccessConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1173.     {
  1174.         if (!class_exists(PropertyAccessor::class)) {
  1175.             return;
  1176.         }
  1177.         $loader->load('property_access.xml');
  1178.         $container
  1179.             ->getDefinition('property_accessor')
  1180.             ->replaceArgument(0$config['magic_call'])
  1181.             ->replaceArgument(1$config['throw_exception_on_invalid_index'])
  1182.             ->replaceArgument(3$config['throw_exception_on_invalid_property_path'])
  1183.             ->replaceArgument(4, new Reference(PropertyReadInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1184.             ->replaceArgument(5, new Reference(PropertyWriteInfoExtractorInterface::class, ContainerInterface::NULL_ON_INVALID_REFERENCE))
  1185.         ;
  1186.     }
  1187.     private function registerSecretsConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1188.     {
  1189.         if (!$this->isConfigEnabled($container$config)) {
  1190.             $container->removeDefinition('console.command.secrets_set');
  1191.             $container->removeDefinition('console.command.secrets_list');
  1192.             $container->removeDefinition('console.command.secrets_remove');
  1193.             $container->removeDefinition('console.command.secrets_generate_key');
  1194.             $container->removeDefinition('console.command.secrets_decrypt_to_local');
  1195.             $container->removeDefinition('console.command.secrets_encrypt_from_local');
  1196.             return;
  1197.         }
  1198.         $loader->load('secrets.xml');
  1199.         $container->getDefinition('secrets.vault')->replaceArgument(0$config['vault_directory']);
  1200.         if ($config['local_dotenv_file']) {
  1201.             $container->getDefinition('secrets.local_vault')->replaceArgument(0$config['local_dotenv_file']);
  1202.         } else {
  1203.             $container->removeDefinition('secrets.local_vault');
  1204.         }
  1205.         if ($config['decryption_env_var']) {
  1206.             if (!preg_match('/^(?:[-.\w]*+:)*+\w++$/'$config['decryption_env_var'])) {
  1207.                 throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.'$config['decryption_env_var']));
  1208.             }
  1209.             if (class_exists(LazyString::class)) {
  1210.                 $container->getDefinition('secrets.decryption_key')->replaceArgument(1$config['decryption_env_var']);
  1211.             } else {
  1212.                 $container->getDefinition('secrets.vault')->replaceArgument(1"%env({$config['decryption_env_var']})%");
  1213.                 $container->removeDefinition('secrets.decryption_key');
  1214.             }
  1215.         } else {
  1216.             $container->getDefinition('secrets.vault')->replaceArgument(1null);
  1217.             $container->removeDefinition('secrets.decryption_key');
  1218.         }
  1219.     }
  1220.     private function registerSecurityCsrfConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1221.     {
  1222.         if (!$this->isConfigEnabled($container$config)) {
  1223.             return;
  1224.         }
  1225.         if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
  1226.             throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
  1227.         }
  1228.         if (!$this->sessionConfigEnabled) {
  1229.             throw new \LogicException('CSRF protection needs sessions to be enabled.');
  1230.         }
  1231.         // Enable services for CSRF protection (even without forms)
  1232.         $loader->load('security_csrf.xml');
  1233.         if (!class_exists(CsrfExtension::class)) {
  1234.             $container->removeDefinition('twig.extension.security_csrf');
  1235.         }
  1236.     }
  1237.     private function registerSerializerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1238.     {
  1239.         $loader->load('serializer.xml');
  1240.         $chainLoader $container->getDefinition('serializer.mapping.chain_loader');
  1241.         if (!class_exists(PropertyAccessor::class)) {
  1242.             $container->removeAlias('serializer.property_accessor');
  1243.             $container->removeDefinition('serializer.normalizer.object');
  1244.         }
  1245.         if (!class_exists(Yaml::class)) {
  1246.             $container->removeDefinition('serializer.encoder.yaml');
  1247.         }
  1248.         if (!class_exists(UnwrappingDenormalizer::class) || !class_exists(PropertyAccessor::class)) {
  1249.             $container->removeDefinition('serializer.denormalizer.unwrapping');
  1250.         }
  1251.         $serializerLoaders = [];
  1252.         if (isset($config['enable_annotations']) && $config['enable_annotations']) {
  1253.             if (!$this->annotationsConfigEnabled) {
  1254.                 throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
  1255.             }
  1256.             $annotationLoader = new Definition(
  1257.                 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
  1258.                 [new Reference('annotation_reader')]
  1259.             );
  1260.             $annotationLoader->setPublic(false);
  1261.             $serializerLoaders[] = $annotationLoader;
  1262.         }
  1263.         $fileRecorder = function ($extension$path) use (&$serializerLoaders) {
  1264.             $definition = new Definition(\in_array($extension, ['yaml''yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
  1265.             $definition->setPublic(false);
  1266.             $serializerLoaders[] = $definition;
  1267.         };
  1268.         foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
  1269.             $configDir is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' $bundle['path'].'/config';
  1270.             if ($container->fileExists($file $configDir.'/serialization.xml'false)) {
  1271.                 $fileRecorder('xml'$file);
  1272.             }
  1273.             if (
  1274.                 $container->fileExists($file $configDir.'/serialization.yaml'false) ||
  1275.                 $container->fileExists($file $configDir.'/serialization.yml'false)
  1276.             ) {
  1277.                 $fileRecorder('yml'$file);
  1278.             }
  1279.             if ($container->fileExists($dir $configDir.'/serialization''/^$/')) {
  1280.                 $this->registerMappingFilesFromDir($dir$fileRecorder);
  1281.             }
  1282.         }
  1283.         $projectDir $container->getParameter('kernel.project_dir');
  1284.         if ($container->fileExists($dir $projectDir.'/config/serializer''/^$/')) {
  1285.             $this->registerMappingFilesFromDir($dir$fileRecorder);
  1286.         }
  1287.         $this->registerMappingFilesFromConfig($container$config$fileRecorder);
  1288.         $chainLoader->replaceArgument(0$serializerLoaders);
  1289.         $container->getDefinition('serializer.mapping.cache_warmer')->replaceArgument(0$serializerLoaders);
  1290.         if (isset($config['name_converter']) && $config['name_converter']) {
  1291.             $container->getDefinition('serializer.name_converter.metadata_aware')->setArgument(1, new Reference($config['name_converter']));
  1292.         }
  1293.         if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
  1294.             $arguments $container->getDefinition('serializer.normalizer.object')->getArguments();
  1295.             $context = ($arguments[6] ?? []) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
  1296.             $container->getDefinition('serializer.normalizer.object')->setArgument(5null);
  1297.             $container->getDefinition('serializer.normalizer.object')->setArgument(6$context);
  1298.         }
  1299.         if ($config['max_depth_handler'] ?? false) {
  1300.             $defaultContext $container->getDefinition('serializer.normalizer.object')->getArgument(6);
  1301.             $defaultContext += ['max_depth_handler' => new Reference($config['max_depth_handler'])];
  1302.             $container->getDefinition('serializer.normalizer.object')->replaceArgument(6$defaultContext);
  1303.         }
  1304.     }
  1305.     private function registerPropertyInfoConfiguration(ContainerBuilder $containerXmlFileLoader $loader)
  1306.     {
  1307.         if (!interface_exists(PropertyInfoExtractorInterface::class)) {
  1308.             throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
  1309.         }
  1310.         $loader->load('property_info.xml');
  1311.         if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) {
  1312.             $definition $container->register('property_info.php_doc_extractor''Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
  1313.             $definition->setPrivate(true);
  1314.             $definition->addTag('property_info.description_extractor', ['priority' => -1000]);
  1315.             $definition->addTag('property_info.type_extractor', ['priority' => -1001]);
  1316.         }
  1317.         if ($container->getParameter('kernel.debug')) {
  1318.             $container->removeDefinition('property_info.cache');
  1319.         }
  1320.     }
  1321.     private function registerLockConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1322.     {
  1323.         $loader->load('lock.xml');
  1324.         foreach ($config['resources'] as $resourceName => $resourceStores) {
  1325.             if (=== \count($resourceStores)) {
  1326.                 continue;
  1327.             }
  1328.             // Generate stores
  1329.             $storeDefinitions = [];
  1330.             foreach ($resourceStores as $storeDsn) {
  1331.                 $storeDsn $container->resolveEnvPlaceholders($storeDsnnull$usedEnvs);
  1332.                 $storeDefinition = new Definition(interface_exists(StoreInterface::class) ? StoreInterface::class : PersistingStoreInterface::class);
  1333.                 $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
  1334.                 $storeDefinition->setArguments([$storeDsn]);
  1335.                 $container->setDefinition($storeDefinitionId '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
  1336.                 $storeDefinition = new Reference($storeDefinitionId);
  1337.                 $storeDefinitions[] = $storeDefinition;
  1338.             }
  1339.             // Wrap array of stores with CombinedStore
  1340.             if (\count($storeDefinitions) > 1) {
  1341.                 $combinedDefinition = new ChildDefinition('lock.store.combined.abstract');
  1342.                 $combinedDefinition->replaceArgument(0$storeDefinitions);
  1343.                 $container->setDefinition('lock.'.$resourceName.'.store'$combinedDefinition);
  1344.             } else {
  1345.                 $container->setAlias('lock.'.$resourceName.'.store', new Alias((string) $storeDefinitions[0], false));
  1346.             }
  1347.             // Generate factories for each resource
  1348.             $factoryDefinition = new ChildDefinition('lock.factory.abstract');
  1349.             $factoryDefinition->replaceArgument(0, new Reference('lock.'.$resourceName.'.store'));
  1350.             $container->setDefinition('lock.'.$resourceName.'.factory'$factoryDefinition);
  1351.             // Generate services for lock instances
  1352.             $lockDefinition = new Definition(Lock::class);
  1353.             $lockDefinition->setPublic(false);
  1354.             $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
  1355.             $lockDefinition->setArguments([$resourceName]);
  1356.             $container->setDefinition('lock.'.$resourceName$lockDefinition);
  1357.             // provide alias for default resource
  1358.             if ('default' === $resourceName) {
  1359.                 $container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store'false));
  1360.                 $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory'false));
  1361.                 $container->setAlias('lock', new Alias('lock.'.$resourceNamefalse));
  1362.                 $container->setAlias(PersistingStoreInterface::class, new Alias('lock.store'false));
  1363.                 $container->setAlias(LockFactory::class, new Alias('lock.factory'false));
  1364.                 $container->setAlias(LockInterface::class, new Alias('lock'false));
  1365.             } else {
  1366.                 $container->registerAliasForArgument('lock.'.$resourceName.'.store'PersistingStoreInterface::class, $resourceName.'.lock.store');
  1367.                 $container->registerAliasForArgument('lock.'.$resourceName.'.factory'LockFactory::class, $resourceName.'.lock.factory');
  1368.                 $container->registerAliasForArgument('lock.'.$resourceNameLockInterface::class, $resourceName.'.lock');
  1369.             }
  1370.         }
  1371.     }
  1372.     private function registerMessengerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $validationConfig)
  1373.     {
  1374.         if (!interface_exists(MessageBusInterface::class)) {
  1375.             throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
  1376.         }
  1377.         $loader->load('messenger.xml');
  1378.         if (class_exists(AmqpTransportFactory::class)) {
  1379.             $container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
  1380.         }
  1381.         if (class_exists(RedisTransportFactory::class)) {
  1382.             $container->getDefinition('messenger.transport.redis.factory')->addTag('messenger.transport_factory');
  1383.         }
  1384.         if (class_exists(AmazonSqsTransportFactory::class)) {
  1385.             $container->getDefinition('messenger.transport.sqs.factory')->addTag('messenger.transport_factory');
  1386.         }
  1387.         if (null === $config['default_bus'] && === \count($config['buses'])) {
  1388.             $config['default_bus'] = key($config['buses']);
  1389.         }
  1390.         $defaultMiddleware = [
  1391.             'before' => [
  1392.                 ['id' => 'add_bus_name_stamp_middleware'],
  1393.                 ['id' => 'reject_redelivered_message_middleware'],
  1394.                 ['id' => 'dispatch_after_current_bus'],
  1395.                 ['id' => 'failed_message_processing_middleware'],
  1396.             ],
  1397.             'after' => [
  1398.                 ['id' => 'send_message'],
  1399.                 ['id' => 'handle_message'],
  1400.             ],
  1401.         ];
  1402.         foreach ($config['buses'] as $busId => $bus) {
  1403.             $middleware $bus['middleware'];
  1404.             if ($bus['default_middleware']) {
  1405.                 if ('allow_no_handlers' === $bus['default_middleware']) {
  1406.                     $defaultMiddleware['after'][1]['arguments'] = [true];
  1407.                 } else {
  1408.                     unset($defaultMiddleware['after'][1]['arguments']);
  1409.                 }
  1410.                 // argument to add_bus_name_stamp_middleware
  1411.                 $defaultMiddleware['before'][0]['arguments'] = [$busId];
  1412.                 $middleware array_merge($defaultMiddleware['before'], $middleware$defaultMiddleware['after']);
  1413.             }
  1414.             foreach ($middleware as $middlewareItem) {
  1415.                 if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation''messenger.middleware.validation'], true)) {
  1416.                     throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
  1417.                 }
  1418.             }
  1419.             if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
  1420.                 array_unshift($middleware, ['id' => 'traceable''arguments' => [$busId]]);
  1421.             }
  1422.             $container->setParameter($busId.'.middleware'$middleware);
  1423.             $container->register($busIdMessageBus::class)->addArgument([])->addTag('messenger.bus');
  1424.             if ($busId === $config['default_bus']) {
  1425.                 $container->setAlias('messenger.default_bus'$busId)->setPublic(true);
  1426.                 $container->setAlias(MessageBusInterface::class, $busId);
  1427.             } else {
  1428.                 $container->registerAliasForArgument($busIdMessageBusInterface::class);
  1429.             }
  1430.         }
  1431.         if (empty($config['transports'])) {
  1432.             $container->removeDefinition('messenger.transport.symfony_serializer');
  1433.             $container->removeDefinition('messenger.transport.amqp.factory');
  1434.             $container->removeDefinition('messenger.transport.redis.factory');
  1435.             $container->removeDefinition('messenger.transport.sqs.factory');
  1436.         } else {
  1437.             $container->getDefinition('messenger.transport.symfony_serializer')
  1438.                 ->replaceArgument(1$config['serializer']['symfony_serializer']['format'])
  1439.                 ->replaceArgument(2$config['serializer']['symfony_serializer']['context']);
  1440.             $container->setAlias('messenger.default_serializer'$config['serializer']['default_serializer']);
  1441.         }
  1442.         $senderAliases = [];
  1443.         $transportRetryReferences = [];
  1444.         foreach ($config['transports'] as $name => $transport) {
  1445.             $serializerId $transport['serializer'] ?? 'messenger.default_serializer';
  1446.             $transportDefinition = (new Definition(TransportInterface::class))
  1447.                 ->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
  1448.                 ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
  1449.                 ->addTag('messenger.receiver', ['alias' => $name])
  1450.             ;
  1451.             $container->setDefinition($transportId 'messenger.transport.'.$name$transportDefinition);
  1452.             $senderAliases[$name] = $transportId;
  1453.             if (null !== $transport['retry_strategy']['service']) {
  1454.                 $transportRetryReferences[$name] = new Reference($transport['retry_strategy']['service']);
  1455.             } else {
  1456.                 $retryServiceId sprintf('messenger.retry.multiplier_retry_strategy.%s'$name);
  1457.                 $retryDefinition = new ChildDefinition('messenger.retry.abstract_multiplier_retry_strategy');
  1458.                 $retryDefinition
  1459.                     ->replaceArgument(0$transport['retry_strategy']['max_retries'])
  1460.                     ->replaceArgument(1$transport['retry_strategy']['delay'])
  1461.                     ->replaceArgument(2$transport['retry_strategy']['multiplier'])
  1462.                     ->replaceArgument(3$transport['retry_strategy']['max_delay']);
  1463.                 $container->setDefinition($retryServiceId$retryDefinition);
  1464.                 $transportRetryReferences[$name] = new Reference($retryServiceId);
  1465.             }
  1466.         }
  1467.         $senderReferences = [];
  1468.         // alias => service_id
  1469.         foreach ($senderAliases as $alias => $serviceId) {
  1470.             $senderReferences[$alias] = new Reference($serviceId);
  1471.         }
  1472.         // service_id => service_id
  1473.         foreach ($senderAliases as $serviceId) {
  1474.             $senderReferences[$serviceId] = new Reference($serviceId);
  1475.         }
  1476.         $messageToSendersMapping = [];
  1477.         foreach ($config['routing'] as $message => $messageConfiguration) {
  1478.             if ('*' !== $message && !class_exists($message) && !interface_exists($messagefalse)) {
  1479.                 throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.'$message));
  1480.             }
  1481.             // make sure senderAliases contains all senders
  1482.             foreach ($messageConfiguration['senders'] as $sender) {
  1483.                 if (!isset($senderReferences[$sender])) {
  1484.                     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));
  1485.                 }
  1486.             }
  1487.             $messageToSendersMapping[$message] = $messageConfiguration['senders'];
  1488.         }
  1489.         $sendersServiceLocator ServiceLocatorTagPass::register($container$senderReferences);
  1490.         $container->getDefinition('messenger.senders_locator')
  1491.             ->replaceArgument(0$messageToSendersMapping)
  1492.             ->replaceArgument(1$sendersServiceLocator)
  1493.         ;
  1494.         $container->getDefinition('messenger.retry.send_failed_message_for_retry_listener')
  1495.             ->replaceArgument(0$sendersServiceLocator)
  1496.         ;
  1497.         $container->getDefinition('messenger.retry_strategy_locator')
  1498.             ->replaceArgument(0$transportRetryReferences);
  1499.         if ($config['failure_transport']) {
  1500.             if (!isset($senderReferences[$config['failure_transport']])) {
  1501.                 throw new LogicException(sprintf('Invalid Messenger configuration: the failure transport "%s" is not a valid transport or service id.'$config['failure_transport']));
  1502.             }
  1503.             $container->getDefinition('messenger.failure.send_failed_message_to_failure_transport_listener')
  1504.                 ->replaceArgument(0$senderReferences[$config['failure_transport']]);
  1505.             $container->getDefinition('console.command.messenger_failed_messages_retry')
  1506.                 ->replaceArgument(0$config['failure_transport']);
  1507.             $container->getDefinition('console.command.messenger_failed_messages_show')
  1508.                 ->replaceArgument(0$config['failure_transport']);
  1509.             $container->getDefinition('console.command.messenger_failed_messages_remove')
  1510.                 ->replaceArgument(0$config['failure_transport']);
  1511.         } else {
  1512.             $container->removeDefinition('messenger.failure.send_failed_message_to_failure_transport_listener');
  1513.             $container->removeDefinition('console.command.messenger_failed_messages_retry');
  1514.             $container->removeDefinition('console.command.messenger_failed_messages_show');
  1515.             $container->removeDefinition('console.command.messenger_failed_messages_remove');
  1516.         }
  1517.     }
  1518.     private function registerCacheConfiguration(array $configContainerBuilder $container)
  1519.     {
  1520.         if (!class_exists(DefaultMarshaller::class)) {
  1521.             $container->removeDefinition('cache.default_marshaller');
  1522.         }
  1523.         $version = new Parameter('container.build_id');
  1524.         $container->getDefinition('cache.adapter.apcu')->replaceArgument(2$version);
  1525.         $container->getDefinition('cache.adapter.system')->replaceArgument(2$version);
  1526.         $container->getDefinition('cache.adapter.filesystem')->replaceArgument(2$config['directory']);
  1527.         if (isset($config['prefix_seed'])) {
  1528.             $container->setParameter('cache.prefix.seed'$config['prefix_seed']);
  1529.         }
  1530.         if ($container->hasParameter('cache.prefix.seed')) {
  1531.             // Inline any env vars referenced in the parameter
  1532.             $container->setParameter('cache.prefix.seed'$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
  1533.         }
  1534.         foreach (['doctrine''psr6''redis''memcached''pdo'] as $name) {
  1535.             if (isset($config[$name 'default_'.$name.'_provider'])) {
  1536.                 $container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container$config[$name]), false));
  1537.             }
  1538.         }
  1539.         foreach (['app''system'] as $name) {
  1540.             $config['pools']['cache.'.$name] = [
  1541.                 'adapters' => [$config[$name]],
  1542.                 'public' => true,
  1543.                 'tags' => false,
  1544.             ];
  1545.         }
  1546.         foreach ($config['pools'] as $name => $pool) {
  1547.             $pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
  1548.             foreach ($pool['adapters'] as $provider => $adapter) {
  1549.                 if ($config['pools'][$adapter]['tags'] ?? false) {
  1550.                     $pool['adapters'][$provider] = $adapter '.'.$adapter.'.inner';
  1551.                 }
  1552.             }
  1553.             if (=== \count($pool['adapters'])) {
  1554.                 if (!isset($pool['provider']) && !\is_int($provider)) {
  1555.                     $pool['provider'] = $provider;
  1556.                 }
  1557.                 $definition = new ChildDefinition($adapter);
  1558.             } else {
  1559.                 $definition = new Definition(ChainAdapter::class, [$pool['adapters'], 0]);
  1560.                 $pool['reset'] = 'reset';
  1561.             }
  1562.             if ($pool['tags']) {
  1563.                 if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
  1564.                     $pool['tags'] = '.'.$pool['tags'].'.inner';
  1565.                 }
  1566.                 $container->register($nameTagAwareAdapter::class)
  1567.                     ->addArgument(new Reference('.'.$name.'.inner'))
  1568.                     ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null)
  1569.                     ->setPublic($pool['public'])
  1570.                 ;
  1571.                 $pool['name'] = $name;
  1572.                 $pool['public'] = false;
  1573.                 $name '.'.$name.'.inner';
  1574.                 if (!\in_array($pool['name'], ['cache.app''cache.system'], true)) {
  1575.                     $container->registerAliasForArgument($pool['name'], TagAwareCacheInterface::class);
  1576.                     $container->registerAliasForArgument($nameCacheInterface::class, $pool['name']);
  1577.                     $container->registerAliasForArgument($nameCacheItemPoolInterface::class, $pool['name']);
  1578.                 }
  1579.             } elseif (!\in_array($name, ['cache.app''cache.system'], true)) {
  1580.                 $container->register('.'.$name.'.taggable'TagAwareAdapter::class)
  1581.                     ->addArgument(new Reference($name))
  1582.                 ;
  1583.                 $container->registerAliasForArgument('.'.$name.'.taggable'TagAwareCacheInterface::class, $name);
  1584.                 $container->registerAliasForArgument($nameCacheInterface::class);
  1585.                 $container->registerAliasForArgument($nameCacheItemPoolInterface::class);
  1586.             }
  1587.             $definition->setPublic($pool['public']);
  1588.             unset($pool['adapters'], $pool['public'], $pool['tags']);
  1589.             $definition->addTag('cache.pool'$pool);
  1590.             $container->setDefinition($name$definition);
  1591.         }
  1592.         if (method_exists(PropertyAccessor::class, 'createCache')) {
  1593.             $propertyAccessDefinition $container->register('cache.property_access'AdapterInterface::class);
  1594.             $propertyAccessDefinition->setPublic(false);
  1595.             if (!$container->getParameter('kernel.debug')) {
  1596.                 $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
  1597.                 $propertyAccessDefinition->setArguments([null0$version, new Reference('logger'ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
  1598.                 $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
  1599.                 $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
  1600.             } else {
  1601.                 $propertyAccessDefinition->setClass(ArrayAdapter::class);
  1602.                 $propertyAccessDefinition->setArguments([0false]);
  1603.             }
  1604.         }
  1605.     }
  1606.     private function registerHttpClientConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader, array $profilerConfig)
  1607.     {
  1608.         $loader->load('http_client.xml');
  1609.         $container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
  1610.         if (!$hasPsr18 interface_exists(ClientInterface::class)) {
  1611.             $container->removeDefinition('psr18.http_client');
  1612.             $container->removeAlias(ClientInterface::class);
  1613.         }
  1614.         if (!interface_exists(HttpClient::class)) {
  1615.             $container->removeDefinition(HttpClient::class);
  1616.         }
  1617.         $httpClientId $this->isConfigEnabled($container$profilerConfig) ? '.debug.http_client.inner' 'http_client';
  1618.         foreach ($config['scoped_clients'] as $name => $scopeConfig) {
  1619.             if ('http_client' === $name) {
  1620.                 throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.'$name));
  1621.             }
  1622.             $scope $scopeConfig['scope'] ?? null;
  1623.             unset($scopeConfig['scope']);
  1624.             if (null === $scope) {
  1625.                 $baseUri $scopeConfig['base_uri'];
  1626.                 unset($scopeConfig['base_uri']);
  1627.                 $container->register($nameScopingHttpClient::class)
  1628.                     ->setFactory([ScopingHttpClient::class, 'forBaseUri'])
  1629.                     ->setArguments([new Reference($httpClientId), $baseUri$scopeConfig])
  1630.                     ->addTag('http_client.client')
  1631.                 ;
  1632.             } else {
  1633.                 $container->register($nameScopingHttpClient::class)
  1634.                     ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope])
  1635.                     ->addTag('http_client.client')
  1636.                 ;
  1637.             }
  1638.             $container->registerAliasForArgument($nameHttpClientInterface::class);
  1639.             if ($hasPsr18) {
  1640.                 $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
  1641.                     ->replaceArgument(0, new Reference($name));
  1642.                 $container->registerAliasForArgument('psr18.'.$nameClientInterface::class, $name);
  1643.             }
  1644.         }
  1645.     }
  1646.     private function registerMailerConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1647.     {
  1648.         if (!class_exists(Mailer::class)) {
  1649.             throw new LogicException('Mailer support cannot be enabled as the component is not installed. Try running "composer require symfony/mailer".');
  1650.         }
  1651.         $loader->load('mailer.xml');
  1652.         $loader->load('mailer_transports.xml');
  1653.         if (!\count($config['transports']) && null === $config['dsn']) {
  1654.             $config['dsn'] = 'smtp://null';
  1655.         }
  1656.         $transports $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
  1657.         $container->getDefinition('mailer.transports')->setArgument(0$transports);
  1658.         $container->getDefinition('mailer.default_transport')->setArgument(0current($transports));
  1659.         $mailer $container->getDefinition('mailer.mailer');
  1660.         if (false === $messageBus $config['message_bus']) {
  1661.             $mailer->replaceArgument(1null);
  1662.         } else {
  1663.             $mailer->replaceArgument(1$messageBus ? new Reference($messageBus) : new Reference('messenger.default_bus'ContainerInterface::NULL_ON_INVALID_REFERENCE));
  1664.         }
  1665.         $classToServices = [
  1666.             GmailTransportFactory::class => 'mailer.transport_factory.gmail',
  1667.             MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
  1668.             MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
  1669.             MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
  1670.             PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
  1671.             SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
  1672.             SesTransportFactory::class => 'mailer.transport_factory.amazon',
  1673.         ];
  1674.         foreach ($classToServices as $class => $service) {
  1675.             if (!class_exists($class)) {
  1676.                 $container->removeDefinition($service);
  1677.             }
  1678.         }
  1679.         $recipients $config['envelope']['recipients'] ?? null;
  1680.         $sender $config['envelope']['sender'] ?? null;
  1681.         $envelopeListener $container->getDefinition('mailer.envelope_listener');
  1682.         $envelopeListener->setArgument(0$sender);
  1683.         $envelopeListener->setArgument(1$recipients);
  1684.     }
  1685.     private function registerNotifierConfiguration(array $configContainerBuilder $containerXmlFileLoader $loader)
  1686.     {
  1687.         if (!class_exists(Notifier::class)) {
  1688.             throw new LogicException('Notifier support cannot be enabled as the component is not installed. Try running "composer require symfony/notifier".');
  1689.         }
  1690.         $loader->load('notifier.xml');
  1691.         $loader->load('notifier_transports.xml');
  1692.         if ($config['chatter_transports']) {
  1693.             $container->getDefinition('chatter.transports')->setArgument(0$config['chatter_transports']);
  1694.         } else {
  1695.             $container->removeDefinition('chatter');
  1696.         }
  1697.         if ($config['texter_transports']) {
  1698.             $container->getDefinition('texter.transports')->setArgument(0$config['texter_transports']);
  1699.         } else {
  1700.             $container->removeDefinition('texter');
  1701.         }
  1702.         if ($this->mailerConfigEnabled) {
  1703.             $sender $container->getDefinition('mailer.envelope_listener')->getArgument(0);
  1704.             $container->getDefinition('notifier.channel.email')->setArgument(2$sender);
  1705.         } else {
  1706.             $container->removeDefinition('notifier.channel.email');
  1707.         }
  1708.         if ($this->messengerConfigEnabled) {
  1709.             if ($config['notification_on_failed_messages']) {
  1710.                 $container->getDefinition('notifier.failed_message_listener')->addTag('kernel.event_subscriber');
  1711.             }
  1712.             // as we have a bus, the channels don't need the transports
  1713.             $container->getDefinition('notifier.channel.chat')->setArgument(0null);
  1714.             if ($container->hasDefinition('notifier.channel.email')) {
  1715.                 $container->getDefinition('notifier.channel.email')->setArgument(0null);
  1716.             }
  1717.             $container->getDefinition('notifier.channel.sms')->setArgument(0null);
  1718.         }
  1719.         $container->getDefinition('notifier.channel_policy')->setArgument(0$config['channel_policy']);
  1720.         $classToServices = [
  1721.             SlackTransportFactory::class => 'notifier.transport_factory.slack',
  1722.             TelegramTransportFactory::class => 'notifier.transport_factory.telegram',
  1723.             MattermostTransportFactory::class => 'notifier.transport_factory.mattermost',
  1724.             NexmoTransportFactory::class => 'notifier.transport_factory.nexmo',
  1725.             RocketChatTransportFactory::class => 'notifier.transport_factory.rocketchat',
  1726.             TwilioTransportFactory::class => 'notifier.transport_factory.twilio',
  1727.             FirebaseTransportFactory::class => 'notifier.transport_factory.firebase',
  1728.             FreeMobileTransportFactory::class => 'notifier.transport_factory.freemobile',
  1729.             OvhCloudTransportFactory::class => 'notifier.transport_factory.ovhcloud',
  1730.             SinchTransportFactory::class => 'notifier.transport_factory.sinch',
  1731.         ];
  1732.         foreach ($classToServices as $class => $service) {
  1733.             if (!class_exists($class)) {
  1734.                 $container->removeDefinition($service);
  1735.             }
  1736.         }
  1737.         if (isset($config['admin_recipients'])) {
  1738.             $notifier $container->getDefinition('notifier');
  1739.             foreach ($config['admin_recipients'] as $i => $recipient) {
  1740.                 $id 'notifier.admin_recipient.'.$i;
  1741.                 $container->setDefinition($id, new Definition(AdminRecipient::class, [$recipient['email'], $recipient['phone']]));
  1742.                 $notifier->addMethodCall('addAdminRecipient', [new Reference($id)]);
  1743.             }
  1744.         }
  1745.     }
  1746.     /**
  1747.      * {@inheritdoc}
  1748.      */
  1749.     public function getXsdValidationBasePath()
  1750.     {
  1751.         return \dirname(__DIR__).'/Resources/config/schema';
  1752.     }
  1753.     public function getNamespace()
  1754.     {
  1755.         return 'http://symfony.com/schema/dic/symfony';
  1756.     }
  1757. }