vendor/symfony/framework-bundle/DependencyInjection/Configuration.php line 126

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\Annotation;
  12. use Doctrine\Common\Annotations\PsrCachedReader;
  13. use Doctrine\Common\Cache\Cache;
  14. use Doctrine\DBAL\Connection;
  15. use Psr\Log\LogLevel;
  16. use Symfony\Bundle\FullStack;
  17. use Symfony\Component\Asset\Package;
  18. use Symfony\Component\Cache\Adapter\DoctrineAdapter;
  19. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  20. use Symfony\Component\Config\Definition\Builder\NodeBuilder;
  21. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  22. use Symfony\Component\Config\Definition\ConfigurationInterface;
  23. use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
  24. use Symfony\Component\DependencyInjection\ContainerBuilder;
  25. use Symfony\Component\DependencyInjection\Exception\LogicException;
  26. use Symfony\Component\Form\Form;
  27. use Symfony\Component\HttpClient\HttpClient;
  28. use Symfony\Component\HttpFoundation\Cookie;
  29. use Symfony\Component\Lock\Lock;
  30. use Symfony\Component\Lock\Store\SemaphoreStore;
  31. use Symfony\Component\Mailer\Mailer;
  32. use Symfony\Component\Messenger\MessageBusInterface;
  33. use Symfony\Component\Notifier\Notifier;
  34. use Symfony\Component\PropertyAccess\PropertyAccessor;
  35. use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
  36. use Symfony\Component\RateLimiter\Policy\TokenBucketLimiter;
  37. use Symfony\Component\Serializer\Serializer;
  38. use Symfony\Component\Translation\Translator;
  39. use Symfony\Component\Uid\Factory\UuidFactory;
  40. use Symfony\Component\Validator\Validation;
  41. use Symfony\Component\WebLink\HttpHeaderSerializer;
  42. use Symfony\Component\Workflow\WorkflowEvents;
  43. /**
  44.  * FrameworkExtension configuration structure.
  45.  */
  46. class Configuration implements ConfigurationInterface
  47. {
  48.     private $debug;
  49.     /**
  50.      * @param bool $debug Whether debugging is enabled or not
  51.      */
  52.     public function __construct(bool $debug)
  53.     {
  54.         $this->debug $debug;
  55.     }
  56.     /**
  57.      * Generates the configuration tree builder.
  58.      *
  59.      * @return TreeBuilder
  60.      */
  61.     public function getConfigTreeBuilder()
  62.     {
  63.         $treeBuilder = new TreeBuilder('framework');
  64.         $rootNode $treeBuilder->getRootNode();
  65.         $rootNode
  66.             ->beforeNormalization()
  67.                 ->ifTrue(function ($v) { return !isset($v['assets']) && isset($v['templating']) && class_exists(Package::class); })
  68.                 ->then(function ($v) {
  69.                     $v['assets'] = [];
  70.                     return $v;
  71.                 })
  72.             ->end()
  73.             ->fixXmlConfig('enabled_locale')
  74.             ->children()
  75.                 ->scalarNode('secret')->end()
  76.                 ->scalarNode('http_method_override')
  77.                     ->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead")
  78.                     ->defaultTrue()
  79.                 ->end()
  80.                 ->scalarNode('ide')->defaultNull()->end()
  81.                 ->booleanNode('test')->end()
  82.                 ->scalarNode('default_locale')->defaultValue('en')->end()
  83.                 ->booleanNode('set_locale_from_accept_language')
  84.                     ->info('Whether to use the Accept-Language HTTP header to set the Request locale (only when the "_locale" request attribute is not passed).')
  85.                     ->defaultFalse()
  86.                 ->end()
  87.                 ->booleanNode('set_content_language_from_locale')
  88.                     ->info('Whether to set the Content-Language HTTP header on the Response using the Request locale.')
  89.                     ->defaultFalse()
  90.                 ->end()
  91.                 ->arrayNode('enabled_locales')
  92.                     ->info('Defines the possible locales for the application. This list is used for generating translations files, but also to restrict which locales are allowed when it is set from Accept-Language header (using "set_locale_from_accept_language").')
  93.                     ->prototype('scalar')->end()
  94.                 ->end()
  95.                 ->arrayNode('trusted_hosts')
  96.                     ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  97.                     ->prototype('scalar')->end()
  98.                 ->end()
  99.                 ->scalarNode('trusted_proxies')->end()
  100.                 ->arrayNode('trusted_headers')
  101.                     ->fixXmlConfig('trusted_header')
  102.                     ->performNoDeepMerging()
  103.                     ->defaultValue(['x-forwarded-for''x-forwarded-port''x-forwarded-proto'])
  104.                     ->beforeNormalization()->ifString()->then(function ($v) { return $v array_map('trim'explode(','$v)) : []; })->end()
  105.                     ->enumPrototype()
  106.                         ->values([
  107.                             'forwarded',
  108.                             'x-forwarded-for''x-forwarded-host''x-forwarded-proto''x-forwarded-port''x-forwarded-prefix',
  109.                         ])
  110.                     ->end()
  111.                 ->end()
  112.                 ->scalarNode('error_controller')
  113.                     ->defaultValue('error_controller')
  114.                 ->end()
  115.             ->end()
  116.         ;
  117.         $willBeAvailable = static function (string $packagestring $classstring $parentPackage null) {
  118.             $parentPackages = (array) $parentPackage;
  119.             $parentPackages[] = 'symfony/framework-bundle';
  120.             return ContainerBuilder::willBeAvailable($package$class$parentPackagestrue);
  121.         };
  122.         $enableIfStandalone = static function (string $packagestring $class) use ($willBeAvailable) {
  123.             return !class_exists(FullStack::class) && $willBeAvailable($package$class) ? 'canBeDisabled' 'canBeEnabled';
  124.         };
  125.         $this->addCsrfSection($rootNode);
  126.         $this->addFormSection($rootNode$enableIfStandalone);
  127.         $this->addHttpCacheSection($rootNode);
  128.         $this->addEsiSection($rootNode);
  129.         $this->addSsiSection($rootNode);
  130.         $this->addFragmentsSection($rootNode);
  131.         $this->addProfilerSection($rootNode);
  132.         $this->addWorkflowSection($rootNode);
  133.         $this->addRouterSection($rootNode);
  134.         $this->addSessionSection($rootNode);
  135.         $this->addRequestSection($rootNode);
  136.         $this->addAssetsSection($rootNode$enableIfStandalone);
  137.         $this->addTranslatorSection($rootNode$enableIfStandalone);
  138.         $this->addValidationSection($rootNode$enableIfStandalone$willBeAvailable);
  139.         $this->addAnnotationsSection($rootNode$willBeAvailable);
  140.         $this->addSerializerSection($rootNode$enableIfStandalone$willBeAvailable);
  141.         $this->addPropertyAccessSection($rootNode$willBeAvailable);
  142.         $this->addPropertyInfoSection($rootNode$enableIfStandalone);
  143.         $this->addCacheSection($rootNode$willBeAvailable);
  144.         $this->addPhpErrorsSection($rootNode);
  145.         $this->addExceptionsSection($rootNode);
  146.         $this->addWebLinkSection($rootNode$enableIfStandalone);
  147.         $this->addLockSection($rootNode$enableIfStandalone);
  148.         $this->addMessengerSection($rootNode$enableIfStandalone);
  149.         $this->addRobotsIndexSection($rootNode);
  150.         $this->addHttpClientSection($rootNode$enableIfStandalone);
  151.         $this->addMailerSection($rootNode$enableIfStandalone);
  152.         $this->addSecretsSection($rootNode);
  153.         $this->addNotifierSection($rootNode$enableIfStandalone);
  154.         $this->addRateLimiterSection($rootNode$enableIfStandalone);
  155.         $this->addUidSection($rootNode$enableIfStandalone);
  156.         return $treeBuilder;
  157.     }
  158.     private function addSecretsSection(ArrayNodeDefinition $rootNode)
  159.     {
  160.         $rootNode
  161.             ->children()
  162.                 ->arrayNode('secrets')
  163.                     ->canBeDisabled()
  164.                     ->children()
  165.                         ->scalarNode('vault_directory')->defaultValue('%kernel.project_dir%/config/secrets/%kernel.runtime_environment%')->cannotBeEmpty()->end()
  166.                         ->scalarNode('local_dotenv_file')->defaultValue('%kernel.project_dir%/.env.%kernel.environment%.local')->end()
  167.                         ->scalarNode('decryption_env_var')->defaultValue('base64:default::SYMFONY_DECRYPTION_SECRET')->end()
  168.                     ->end()
  169.                 ->end()
  170.             ->end()
  171.         ;
  172.     }
  173.     private function addCsrfSection(ArrayNodeDefinition $rootNode)
  174.     {
  175.         $rootNode
  176.             ->children()
  177.                 ->arrayNode('csrf_protection')
  178.                     ->treatFalseLike(['enabled' => false])
  179.                     ->treatTrueLike(['enabled' => true])
  180.                     ->treatNullLike(['enabled' => true])
  181.                     ->addDefaultsIfNotSet()
  182.                     ->children()
  183.                         // defaults to framework.session.enabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class)
  184.                         ->booleanNode('enabled')->defaultNull()->end()
  185.                     ->end()
  186.                 ->end()
  187.             ->end()
  188.         ;
  189.     }
  190.     private function addFormSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  191.     {
  192.         $rootNode
  193.             ->children()
  194.                 ->arrayNode('form')
  195.                     ->info('form configuration')
  196.                     ->{$enableIfStandalone('symfony/form'Form::class)}()
  197.                     ->children()
  198.                         ->arrayNode('csrf_protection')
  199.                             ->treatFalseLike(['enabled' => false])
  200.                             ->treatTrueLike(['enabled' => true])
  201.                             ->treatNullLike(['enabled' => true])
  202.                             ->addDefaultsIfNotSet()
  203.                             ->children()
  204.                                 ->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled
  205.                                 ->scalarNode('field_name')->defaultValue('_token')->end()
  206.                             ->end()
  207.                         ->end()
  208.                         // to be set to false in Symfony 6.0
  209.                         ->booleanNode('legacy_error_messages')
  210.                             ->defaultTrue()
  211.                             ->validate()
  212.                                 ->ifTrue()
  213.                                 ->then(function ($v) {
  214.                                     trigger_deprecation('symfony/framework-bundle''5.2''Setting the "framework.form.legacy_error_messages" option to "true" is deprecated. It will have no effect as of Symfony 6.0.');
  215.                                     return $v;
  216.                                 })
  217.                             ->end()
  218.                         ->end()
  219.                     ->end()
  220.                 ->end()
  221.             ->end()
  222.         ;
  223.     }
  224.     private function addHttpCacheSection(ArrayNodeDefinition $rootNode)
  225.     {
  226.         $rootNode
  227.             ->children()
  228.                 ->arrayNode('http_cache')
  229.                     ->info('HTTP cache configuration')
  230.                     ->canBeEnabled()
  231.                     ->fixXmlConfig('private_header')
  232.                     ->children()
  233.                         ->booleanNode('debug')->defaultValue('%kernel.debug%')->end()
  234.                         ->enumNode('trace_level')
  235.                             ->values(['none''short''full'])
  236.                         ->end()
  237.                         ->scalarNode('trace_header')->end()
  238.                         ->integerNode('default_ttl')->end()
  239.                         ->arrayNode('private_headers')
  240.                             ->performNoDeepMerging()
  241.                             ->scalarPrototype()->end()
  242.                         ->end()
  243.                         ->booleanNode('allow_reload')->end()
  244.                         ->booleanNode('allow_revalidate')->end()
  245.                         ->integerNode('stale_while_revalidate')->end()
  246.                         ->integerNode('stale_if_error')->end()
  247.                     ->end()
  248.                 ->end()
  249.             ->end()
  250.         ;
  251.     }
  252.     private function addEsiSection(ArrayNodeDefinition $rootNode)
  253.     {
  254.         $rootNode
  255.             ->children()
  256.                 ->arrayNode('esi')
  257.                     ->info('esi configuration')
  258.                     ->canBeEnabled()
  259.                 ->end()
  260.             ->end()
  261.         ;
  262.     }
  263.     private function addSsiSection(ArrayNodeDefinition $rootNode)
  264.     {
  265.         $rootNode
  266.             ->children()
  267.                 ->arrayNode('ssi')
  268.                     ->info('ssi configuration')
  269.                     ->canBeEnabled()
  270.                 ->end()
  271.             ->end();
  272.     }
  273.     private function addFragmentsSection(ArrayNodeDefinition $rootNode)
  274.     {
  275.         $rootNode
  276.             ->children()
  277.                 ->arrayNode('fragments')
  278.                     ->info('fragments configuration')
  279.                     ->canBeEnabled()
  280.                     ->children()
  281.                         ->scalarNode('hinclude_default_template')->defaultNull()->end()
  282.                         ->scalarNode('path')->defaultValue('/_fragment')->end()
  283.                     ->end()
  284.                 ->end()
  285.             ->end()
  286.         ;
  287.     }
  288.     private function addProfilerSection(ArrayNodeDefinition $rootNode)
  289.     {
  290.         $rootNode
  291.             ->children()
  292.                 ->arrayNode('profiler')
  293.                     ->info('profiler configuration')
  294.                     ->canBeEnabled()
  295.                     ->children()
  296.                         ->booleanNode('collect')->defaultTrue()->end()
  297.                         ->scalarNode('collect_parameter')->defaultNull()->info('The name of the parameter to use to enable or disable collection on a per request basis')->end()
  298.                         ->booleanNode('only_exceptions')->defaultFalse()->end()
  299.                         ->booleanNode('only_main_requests')->defaultFalse()->end()
  300.                         ->booleanNode('only_master_requests')->setDeprecated('symfony/framework-bundle''5.3''Option "%node%" at "%path%" is deprecated, use "only_main_requests" instead.')->defaultFalse()->end()
  301.                         ->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end()
  302.                     ->end()
  303.                 ->end()
  304.             ->end()
  305.         ;
  306.     }
  307.     private function addWorkflowSection(ArrayNodeDefinition $rootNode)
  308.     {
  309.         $rootNode
  310.             ->fixXmlConfig('workflow')
  311.             ->children()
  312.                 ->arrayNode('workflows')
  313.                     ->canBeEnabled()
  314.                     ->beforeNormalization()
  315.                         ->always(function ($v) {
  316.                             if (\is_array($v) && true === $v['enabled']) {
  317.                                 $workflows $v;
  318.                                 unset($workflows['enabled']);
  319.                                 if (=== \count($workflows) && isset($workflows[0]['enabled']) && === \count($workflows[0])) {
  320.                                     $workflows = [];
  321.                                 }
  322.                                 if (=== \count($workflows) && isset($workflows['workflows']) && !array_is_list($workflows['workflows']) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail''type''marking_store''supports''support_strategy''initial_marking''places''transitions']))) {
  323.                                     $workflows $workflows['workflows'];
  324.                                 }
  325.                                 foreach ($workflows as $key => $workflow) {
  326.                                     if (isset($workflow['enabled']) && false === $workflow['enabled']) {
  327.                                         throw new LogicException(sprintf('Cannot disable a single workflow. Remove the configuration for the workflow "%s" instead.'$key));
  328.                                     }
  329.                                     unset($workflows[$key]['enabled']);
  330.                                 }
  331.                                 $v = [
  332.                                     'enabled' => true,
  333.                                     'workflows' => $workflows,
  334.                                 ];
  335.                             }
  336.                             return $v;
  337.                         })
  338.                     ->end()
  339.                     ->children()
  340.                         ->arrayNode('workflows')
  341.                             ->useAttributeAsKey('name')
  342.                             ->prototype('array')
  343.                                 ->fixXmlConfig('support')
  344.                                 ->fixXmlConfig('place')
  345.                                 ->fixXmlConfig('transition')
  346.                                 ->fixXmlConfig('event_to_dispatch''events_to_dispatch')
  347.                                 ->children()
  348.                                     ->arrayNode('audit_trail')
  349.                                         ->canBeEnabled()
  350.                                     ->end()
  351.                                     ->enumNode('type')
  352.                                         ->values(['workflow''state_machine'])
  353.                                         ->defaultValue('state_machine')
  354.                                     ->end()
  355.                                     ->arrayNode('marking_store')
  356.                                         ->children()
  357.                                             ->enumNode('type')
  358.                                                 ->values(['method'])
  359.                                             ->end()
  360.                                             ->scalarNode('property')
  361.                                                 ->defaultValue('marking')
  362.                                             ->end()
  363.                                             ->scalarNode('service')
  364.                                                 ->cannotBeEmpty()
  365.                                             ->end()
  366.                                         ->end()
  367.                                     ->end()
  368.                                     ->arrayNode('supports')
  369.                                         ->beforeNormalization()
  370.                                             ->ifString()
  371.                                             ->then(function ($v) { return [$v]; })
  372.                                         ->end()
  373.                                         ->prototype('scalar')
  374.                                             ->cannotBeEmpty()
  375.                                             ->validate()
  376.                                                 ->ifTrue(function ($v) { return !class_exists($v) && !interface_exists($vfalse); })
  377.                                                 ->thenInvalid('The supported class or interface "%s" does not exist.')
  378.                                             ->end()
  379.                                         ->end()
  380.                                     ->end()
  381.                                     ->scalarNode('support_strategy')
  382.                                         ->cannotBeEmpty()
  383.                                     ->end()
  384.                                     ->arrayNode('initial_marking')
  385.                                         ->beforeNormalization()->castToArray()->end()
  386.                                         ->defaultValue([])
  387.                                         ->prototype('scalar')->end()
  388.                                     ->end()
  389.                                     ->variableNode('events_to_dispatch')
  390.                                         ->defaultValue(null)
  391.                                         ->validate()
  392.                                             ->ifTrue(function ($v) {
  393.                                                 if (null === $v) {
  394.                                                     return false;
  395.                                                 }
  396.                                                 if (!\is_array($v)) {
  397.                                                     return true;
  398.                                                 }
  399.                                                 foreach ($v as $value) {
  400.                                                     if (!\is_string($value)) {
  401.                                                         return true;
  402.                                                     }
  403.                                                     if (class_exists(WorkflowEvents::class) && !\in_array($valueWorkflowEvents::ALIASES)) {
  404.                                                         return true;
  405.                                                     }
  406.                                                 }
  407.                                                 return false;
  408.                                             })
  409.                                             ->thenInvalid('The value must be "null" or an array of workflow events (like ["workflow.enter"]).')
  410.                                         ->end()
  411.                                         ->info('Select which Transition events should be dispatched for this Workflow')
  412.                                         ->example(['workflow.enter''workflow.transition'])
  413.                                     ->end()
  414.                                     ->arrayNode('places')
  415.                                         ->beforeNormalization()
  416.                                             ->always()
  417.                                             ->then(function ($places) {
  418.                                                 // It's an indexed array of shape  ['place1', 'place2']
  419.                                                 if (isset($places[0]) && \is_string($places[0])) {
  420.                                                     return array_map(function (string $place) {
  421.                                                         return ['name' => $place];
  422.                                                     }, $places);
  423.                                                 }
  424.                                                 // It's an indexed array, we let the validation occur
  425.                                                 if (isset($places[0]) && \is_array($places[0])) {
  426.                                                     return $places;
  427.                                                 }
  428.                                                 foreach ($places as $name => $place) {
  429.                                                     if (\is_array($place) && \array_key_exists('name'$place)) {
  430.                                                         continue;
  431.                                                     }
  432.                                                     $place['name'] = $name;
  433.                                                     $places[$name] = $place;
  434.                                                 }
  435.                                                 return array_values($places);
  436.                                             })
  437.                                         ->end()
  438.                                         ->isRequired()
  439.                                         ->requiresAtLeastOneElement()
  440.                                         ->prototype('array')
  441.                                             ->children()
  442.                                                 ->scalarNode('name')
  443.                                                     ->isRequired()
  444.                                                     ->cannotBeEmpty()
  445.                                                 ->end()
  446.                                                 ->arrayNode('metadata')
  447.                                                     ->normalizeKeys(false)
  448.                                                     ->defaultValue([])
  449.                                                     ->example(['color' => 'blue''description' => 'Workflow to manage article.'])
  450.                                                     ->prototype('variable')
  451.                                                     ->end()
  452.                                                 ->end()
  453.                                             ->end()
  454.                                         ->end()
  455.                                     ->end()
  456.                                     ->arrayNode('transitions')
  457.                                         ->beforeNormalization()
  458.                                             ->always()
  459.                                             ->then(function ($transitions) {
  460.                                                 // It's an indexed array, we let the validation occur
  461.                                                 if (isset($transitions[0]) && \is_array($transitions[0])) {
  462.                                                     return $transitions;
  463.                                                 }
  464.                                                 foreach ($transitions as $name => $transition) {
  465.                                                     if (\is_array($transition) && \array_key_exists('name'$transition)) {
  466.                                                         continue;
  467.                                                     }
  468.                                                     $transition['name'] = $name;
  469.                                                     $transitions[$name] = $transition;
  470.                                                 }
  471.                                                 return $transitions;
  472.                                             })
  473.                                         ->end()
  474.                                         ->isRequired()
  475.                                         ->requiresAtLeastOneElement()
  476.                                         ->prototype('array')
  477.                                             ->children()
  478.                                                 ->scalarNode('name')
  479.                                                     ->isRequired()
  480.                                                     ->cannotBeEmpty()
  481.                                                 ->end()
  482.                                                 ->scalarNode('guard')
  483.                                                     ->cannotBeEmpty()
  484.                                                     ->info('An expression to block the transition')
  485.                                                     ->example('is_fully_authenticated() and is_granted(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
  486.                                                 ->end()
  487.                                                 ->arrayNode('from')
  488.                                                     ->beforeNormalization()
  489.                                                         ->ifString()
  490.                                                         ->then(function ($v) { return [$v]; })
  491.                                                     ->end()
  492.                                                     ->requiresAtLeastOneElement()
  493.                                                     ->prototype('scalar')
  494.                                                         ->cannotBeEmpty()
  495.                                                     ->end()
  496.                                                 ->end()
  497.                                                 ->arrayNode('to')
  498.                                                     ->beforeNormalization()
  499.                                                         ->ifString()
  500.                                                         ->then(function ($v) { return [$v]; })
  501.                                                     ->end()
  502.                                                     ->requiresAtLeastOneElement()
  503.                                                     ->prototype('scalar')
  504.                                                         ->cannotBeEmpty()
  505.                                                     ->end()
  506.                                                 ->end()
  507.                                                 ->arrayNode('metadata')
  508.                                                     ->normalizeKeys(false)
  509.                                                     ->defaultValue([])
  510.                                                     ->example(['color' => 'blue''description' => 'Workflow to manage article.'])
  511.                                                     ->prototype('variable')
  512.                                                     ->end()
  513.                                                 ->end()
  514.                                             ->end()
  515.                                         ->end()
  516.                                     ->end()
  517.                                     ->arrayNode('metadata')
  518.                                         ->normalizeKeys(false)
  519.                                         ->defaultValue([])
  520.                                         ->example(['color' => 'blue''description' => 'Workflow to manage article.'])
  521.                                         ->prototype('variable')
  522.                                         ->end()
  523.                                     ->end()
  524.                                 ->end()
  525.                                 ->validate()
  526.                                     ->ifTrue(function ($v) {
  527.                                         return $v['supports'] && isset($v['support_strategy']);
  528.                                     })
  529.                                     ->thenInvalid('"supports" and "support_strategy" cannot be used together.')
  530.                                 ->end()
  531.                                 ->validate()
  532.                                     ->ifTrue(function ($v) {
  533.                                         return !$v['supports'] && !isset($v['support_strategy']);
  534.                                     })
  535.                                     ->thenInvalid('"supports" or "support_strategy" should be configured.')
  536.                                 ->end()
  537.                                 ->beforeNormalization()
  538.                                         ->always()
  539.                                         ->then(function ($values) {
  540.                                             // Special case to deal with XML when the user wants an empty array
  541.                                             if (\array_key_exists('event_to_dispatch'$values) && null === $values['event_to_dispatch']) {
  542.                                                 $values['events_to_dispatch'] = [];
  543.                                                 unset($values['event_to_dispatch']);
  544.                                             }
  545.                                             return $values;
  546.                                         })
  547.                                 ->end()
  548.                             ->end()
  549.                         ->end()
  550.                     ->end()
  551.                 ->end()
  552.             ->end()
  553.         ;
  554.     }
  555.     private function addRouterSection(ArrayNodeDefinition $rootNode)
  556.     {
  557.         $rootNode
  558.             ->children()
  559.                 ->arrayNode('router')
  560.                     ->info('router configuration')
  561.                     ->canBeEnabled()
  562.                     ->children()
  563.                         ->scalarNode('resource')->isRequired()->end()
  564.                         ->scalarNode('type')->end()
  565.                         ->scalarNode('default_uri')
  566.                             ->info('The default URI used to generate URLs in a non-HTTP context')
  567.                             ->defaultNull()
  568.                         ->end()
  569.                         ->scalarNode('http_port')->defaultValue(80)->end()
  570.                         ->scalarNode('https_port')->defaultValue(443)->end()
  571.                         ->scalarNode('strict_requirements')
  572.                             ->info(
  573.                                 "set to true to throw an exception when a parameter does not match the requirements\n".
  574.                                 "set to false to disable exceptions when a parameter does not match the requirements (and return null instead)\n".
  575.                                 "set to null to disable parameter checks against requirements\n".
  576.                                 "'true' is the preferred configuration in development mode, while 'false' or 'null' might be preferred in production"
  577.                             )
  578.                             ->defaultTrue()
  579.                         ->end()
  580.                         ->booleanNode('utf8')->defaultNull()->end()
  581.                     ->end()
  582.                 ->end()
  583.             ->end()
  584.         ;
  585.     }
  586.     private function addSessionSection(ArrayNodeDefinition $rootNode)
  587.     {
  588.         $rootNode
  589.             ->children()
  590.                 ->arrayNode('session')
  591.                     ->info('session configuration')
  592.                     ->canBeEnabled()
  593.                     ->beforeNormalization()
  594.                         ->ifTrue(function ($v) {
  595.                             return \is_array($v) && isset($v['storage_id']) && isset($v['storage_factory_id']);
  596.                         })
  597.                         ->thenInvalid('You cannot use both "storage_id" and "storage_factory_id" at the same time under "framework.session"')
  598.                     ->end()
  599.                     ->children()
  600.                         ->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
  601.                         ->scalarNode('storage_factory_id')->defaultNull()->end()
  602.                         ->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
  603.                         ->scalarNode('name')
  604.                             ->validate()
  605.                                 ->ifTrue(function ($v) {
  606.                                     parse_str($v$parsed);
  607.                                     return implode('&'array_keys($parsed)) !== (string) $v;
  608.                                 })
  609.                                 ->thenInvalid('Session name %s contains illegal character(s)')
  610.                             ->end()
  611.                         ->end()
  612.                         ->scalarNode('cookie_lifetime')->end()
  613.                         ->scalarNode('cookie_path')->end()
  614.                         ->scalarNode('cookie_domain')->end()
  615.                         ->enumNode('cookie_secure')->values([truefalse'auto'])->end()
  616.                         ->booleanNode('cookie_httponly')->defaultTrue()->end()
  617.                         ->enumNode('cookie_samesite')->values([nullCookie::SAMESITE_LAXCookie::SAMESITE_STRICTCookie::SAMESITE_NONE])->defaultNull()->end()
  618.                         ->booleanNode('use_cookies')->end()
  619.                         ->scalarNode('gc_divisor')->end()
  620.                         ->scalarNode('gc_probability')->defaultValue(1)->end()
  621.                         ->scalarNode('gc_maxlifetime')->end()
  622.                         ->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end()
  623.                         ->integerNode('metadata_update_threshold')
  624.                             ->defaultValue(0)
  625.                             ->info('seconds to wait between 2 session metadata updates')
  626.                         ->end()
  627.                         ->integerNode('sid_length')
  628.                             ->min(22)
  629.                             ->max(256)
  630.                         ->end()
  631.                         ->integerNode('sid_bits_per_character')
  632.                             ->min(4)
  633.                             ->max(6)
  634.                         ->end()
  635.                     ->end()
  636.                 ->end()
  637.             ->end()
  638.         ;
  639.     }
  640.     private function addRequestSection(ArrayNodeDefinition $rootNode)
  641.     {
  642.         $rootNode
  643.             ->children()
  644.                 ->arrayNode('request')
  645.                     ->info('request configuration')
  646.                     ->canBeEnabled()
  647.                     ->fixXmlConfig('format')
  648.                     ->children()
  649.                         ->arrayNode('formats')
  650.                             ->useAttributeAsKey('name')
  651.                             ->prototype('array')
  652.                                 ->beforeNormalization()
  653.                                     ->ifTrue(function ($v) { return \is_array($v) && isset($v['mime_type']); })
  654.                                     ->then(function ($v) { return $v['mime_type']; })
  655.                                 ->end()
  656.                                 ->beforeNormalization()->castToArray()->end()
  657.                                 ->prototype('scalar')->end()
  658.                             ->end()
  659.                         ->end()
  660.                     ->end()
  661.                 ->end()
  662.             ->end()
  663.         ;
  664.     }
  665.     private function addAssetsSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  666.     {
  667.         $rootNode
  668.             ->children()
  669.                 ->arrayNode('assets')
  670.                     ->info('assets configuration')
  671.                     ->{$enableIfStandalone('symfony/asset'Package::class)}()
  672.                     ->fixXmlConfig('base_url')
  673.                     ->children()
  674.                         ->booleanNode('strict_mode')
  675.                             ->info('Throw an exception if an entry is missing from the manifest.json')
  676.                             ->defaultFalse()
  677.                         ->end()
  678.                         ->scalarNode('version_strategy')->defaultNull()->end()
  679.                         ->scalarNode('version')->defaultNull()->end()
  680.                         ->scalarNode('version_format')->defaultValue('%%s?%%s')->end()
  681.                         ->scalarNode('json_manifest_path')->defaultNull()->end()
  682.                         ->scalarNode('base_path')->defaultValue('')->end()
  683.                         ->arrayNode('base_urls')
  684.                             ->requiresAtLeastOneElement()
  685.                             ->beforeNormalization()->castToArray()->end()
  686.                             ->prototype('scalar')->end()
  687.                         ->end()
  688.                     ->end()
  689.                     ->validate()
  690.                         ->ifTrue(function ($v) {
  691.                             return isset($v['version_strategy']) && isset($v['version']);
  692.                         })
  693.                         ->thenInvalid('You cannot use both "version_strategy" and "version" at the same time under "assets".')
  694.                     ->end()
  695.                     ->validate()
  696.                         ->ifTrue(function ($v) {
  697.                             return isset($v['version_strategy']) && isset($v['json_manifest_path']);
  698.                         })
  699.                         ->thenInvalid('You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".')
  700.                     ->end()
  701.                     ->validate()
  702.                         ->ifTrue(function ($v) {
  703.                             return isset($v['version']) && isset($v['json_manifest_path']);
  704.                         })
  705.                         ->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets".')
  706.                     ->end()
  707.                     ->fixXmlConfig('package')
  708.                     ->children()
  709.                         ->arrayNode('packages')
  710.                             ->normalizeKeys(false)
  711.                             ->useAttributeAsKey('name')
  712.                             ->prototype('array')
  713.                                 ->fixXmlConfig('base_url')
  714.                                 ->children()
  715.                                     ->booleanNode('strict_mode')
  716.                                         ->info('Throw an exception if an entry is missing from the manifest.json')
  717.                                         ->defaultFalse()
  718.                                     ->end()
  719.                                     ->scalarNode('version_strategy')->defaultNull()->end()
  720.                                     ->scalarNode('version')
  721.                                         ->beforeNormalization()
  722.                                         ->ifTrue(function ($v) { return '' === $v; })
  723.                                         ->then(function ($v) { return; })
  724.                                         ->end()
  725.                                     ->end()
  726.                                     ->scalarNode('version_format')->defaultNull()->end()
  727.                                     ->scalarNode('json_manifest_path')->defaultNull()->end()
  728.                                     ->scalarNode('base_path')->defaultValue('')->end()
  729.                                     ->arrayNode('base_urls')
  730.                                         ->requiresAtLeastOneElement()
  731.                                         ->beforeNormalization()->castToArray()->end()
  732.                                         ->prototype('scalar')->end()
  733.                                     ->end()
  734.                                 ->end()
  735.                                 ->validate()
  736.                                     ->ifTrue(function ($v) {
  737.                                         return isset($v['version_strategy']) && isset($v['version']);
  738.                                     })
  739.                                     ->thenInvalid('You cannot use both "version_strategy" and "version" at the same time under "assets" packages.')
  740.                                 ->end()
  741.                                 ->validate()
  742.                                     ->ifTrue(function ($v) {
  743.                                         return isset($v['version_strategy']) && isset($v['json_manifest_path']);
  744.                                     })
  745.                                     ->thenInvalid('You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.')
  746.                                 ->end()
  747.                                 ->validate()
  748.                                     ->ifTrue(function ($v) {
  749.                                         return isset($v['version']) && isset($v['json_manifest_path']);
  750.                                     })
  751.                                     ->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.')
  752.                                 ->end()
  753.                             ->end()
  754.                         ->end()
  755.                     ->end()
  756.                 ->end()
  757.             ->end()
  758.         ;
  759.     }
  760.     private function addTranslatorSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  761.     {
  762.         $rootNode
  763.             ->children()
  764.                 ->arrayNode('translator')
  765.                     ->info('translator configuration')
  766.                     ->{$enableIfStandalone('symfony/translation'Translator::class)}()
  767.                     ->fixXmlConfig('fallback')
  768.                     ->fixXmlConfig('path')
  769.                     ->fixXmlConfig('enabled_locale')
  770.                     ->fixXmlConfig('provider')
  771.                     ->children()
  772.                         ->arrayNode('fallbacks')
  773.                             ->info('Defaults to the value of "default_locale".')
  774.                             ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  775.                             ->prototype('scalar')->end()
  776.                             ->defaultValue([])
  777.                         ->end()
  778.                         ->booleanNode('logging')->defaultValue(false)->end()
  779.                         ->scalarNode('formatter')->defaultValue('translator.formatter.default')->end()
  780.                         ->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/translations')->end()
  781.                         ->scalarNode('default_path')
  782.                             ->info('The default path used to load translations')
  783.                             ->defaultValue('%kernel.project_dir%/translations')
  784.                         ->end()
  785.                         ->arrayNode('paths')
  786.                             ->prototype('scalar')->end()
  787.                         ->end()
  788.                         ->arrayNode('enabled_locales')
  789.                             ->setDeprecated('symfony/framework-bundle''5.3''Option "%node%" at "%path%" is deprecated, set the "framework.enabled_locales" option instead.')
  790.                             ->prototype('scalar')->end()
  791.                             ->defaultValue([])
  792.                         ->end()
  793.                         ->arrayNode('pseudo_localization')
  794.                             ->canBeEnabled()
  795.                             ->fixXmlConfig('localizable_html_attribute')
  796.                             ->children()
  797.                                 ->booleanNode('accents')->defaultTrue()->end()
  798.                                 ->floatNode('expansion_factor')
  799.                                     ->min(1.0)
  800.                                     ->defaultValue(1.0)
  801.                                 ->end()
  802.                                 ->booleanNode('brackets')->defaultTrue()->end()
  803.                                 ->booleanNode('parse_html')->defaultFalse()->end()
  804.                                 ->arrayNode('localizable_html_attributes')
  805.                                     ->prototype('scalar')->end()
  806.                                 ->end()
  807.                             ->end()
  808.                         ->end()
  809.                         ->arrayNode('providers')
  810.                             ->info('Translation providers you can read/write your translations from')
  811.                             ->useAttributeAsKey('name')
  812.                             ->prototype('array')
  813.                                 ->fixXmlConfig('domain')
  814.                                 ->fixXmlConfig('locale')
  815.                                 ->children()
  816.                                     ->scalarNode('dsn')->end()
  817.                                     ->arrayNode('domains')
  818.                                         ->prototype('scalar')->end()
  819.                                         ->defaultValue([])
  820.                                     ->end()
  821.                                     ->arrayNode('locales')
  822.                                         ->prototype('scalar')->end()
  823.                                         ->defaultValue([])
  824.                                         ->info('If not set, all locales listed under framework.enabled_locales are used.')
  825.                                     ->end()
  826.                                 ->end()
  827.                             ->end()
  828.                             ->defaultValue([])
  829.                         ->end()
  830.                     ->end()
  831.                 ->end()
  832.             ->end()
  833.         ;
  834.     }
  835.     private function addValidationSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone, callable $willBeAvailable)
  836.     {
  837.         $rootNode
  838.             ->children()
  839.                 ->arrayNode('validation')
  840.                     ->info('validation configuration')
  841.                     ->{$enableIfStandalone('symfony/validator'Validation::class)}()
  842.                     ->children()
  843.                         ->scalarNode('cache')->end()
  844.                         ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && (\PHP_VERSION_ID >= 80000 || $willBeAvailable('doctrine/annotations'Annotation::class, 'symfony/validator')) ? 'defaultTrue' 'defaultFalse'}()->end()
  845.                         ->arrayNode('static_method')
  846.                             ->defaultValue(['loadValidatorMetadata'])
  847.                             ->prototype('scalar')->end()
  848.                             ->treatFalseLike([])
  849.                             ->validate()->castToArray()->end()
  850.                         ->end()
  851.                         ->scalarNode('translation_domain')->defaultValue('validators')->end()
  852.                         ->enumNode('email_validation_mode')->values(['html5''loose''strict'])->end()
  853.                         ->arrayNode('mapping')
  854.                             ->addDefaultsIfNotSet()
  855.                             ->fixXmlConfig('path')
  856.                             ->children()
  857.                                 ->arrayNode('paths')
  858.                                     ->prototype('scalar')->end()
  859.                                 ->end()
  860.                             ->end()
  861.                         ->end()
  862.                         ->arrayNode('not_compromised_password')
  863.                             ->canBeDisabled()
  864.                             ->children()
  865.                                 ->booleanNode('enabled')
  866.                                     ->defaultTrue()
  867.                                     ->info('When disabled, compromised passwords will be accepted as valid.')
  868.                                 ->end()
  869.                                 ->scalarNode('endpoint')
  870.                                     ->defaultNull()
  871.                                     ->info('API endpoint for the NotCompromisedPassword Validator.')
  872.                                 ->end()
  873.                             ->end()
  874.                         ->end()
  875.                         ->arrayNode('auto_mapping')
  876.                             ->info('A collection of namespaces for which auto-mapping will be enabled by default, or null to opt-in with the EnableAutoMapping constraint.')
  877.                             ->example([
  878.                                 'App\\Entity\\' => [],
  879.                                 'App\\WithSpecificLoaders\\' => ['validator.property_info_loader'],
  880.                             ])
  881.                             ->useAttributeAsKey('namespace')
  882.                             ->normalizeKeys(false)
  883.                             ->beforeNormalization()
  884.                                 ->ifArray()
  885.                                 ->then(function (array $values): array {
  886.                                     foreach ($values as $k => $v) {
  887.                                         if (isset($v['service'])) {
  888.                                             continue;
  889.                                         }
  890.                                         if (isset($v['namespace'])) {
  891.                                             $values[$k]['services'] = [];
  892.                                             continue;
  893.                                         }
  894.                                         if (!\is_array($v)) {
  895.                                             $values[$v]['services'] = [];
  896.                                             unset($values[$k]);
  897.                                             continue;
  898.                                         }
  899.                                         $tmp $v;
  900.                                         unset($values[$k]);
  901.                                         $values[$k]['services'] = $tmp;
  902.                                     }
  903.                                     return $values;
  904.                                 })
  905.                             ->end()
  906.                             ->arrayPrototype()
  907.                                 ->fixXmlConfig('service')
  908.                                 ->children()
  909.                                     ->arrayNode('services')
  910.                                         ->prototype('scalar')->end()
  911.                                     ->end()
  912.                                 ->end()
  913.                             ->end()
  914.                         ->end()
  915.                     ->end()
  916.                 ->end()
  917.             ->end()
  918.         ;
  919.     }
  920.     private function addAnnotationsSection(ArrayNodeDefinition $rootNode, callable $willBeAvailable)
  921.     {
  922.         $doctrineCache $willBeAvailable('doctrine/cache'Cache::class, 'doctrine/annotations');
  923.         $psr6Cache $willBeAvailable('symfony/cache'PsrCachedReader::class, 'doctrine/annotations');
  924.         $rootNode
  925.             ->children()
  926.                 ->arrayNode('annotations')
  927.                     ->info('annotation configuration')
  928.                     ->{$willBeAvailable('doctrine/annotations'Annotation::class) ? 'canBeDisabled' 'canBeEnabled'}()
  929.                     ->children()
  930.                         ->scalarNode('cache')->defaultValue(($doctrineCache || $psr6Cache) ? 'php_array' 'none')->end()
  931.                         ->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
  932.                         ->booleanNode('debug')->defaultValue($this->debug)->end()
  933.                     ->end()
  934.                 ->end()
  935.             ->end()
  936.         ;
  937.     }
  938.     private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone, callable $willBeAvailable)
  939.     {
  940.         $rootNode
  941.             ->children()
  942.                 ->arrayNode('serializer')
  943.                     ->info('serializer configuration')
  944.                     ->{$enableIfStandalone('symfony/serializer'Serializer::class)}()
  945.                     ->children()
  946.                         ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && (\PHP_VERSION_ID >= 80000 || $willBeAvailable('doctrine/annotations'Annotation::class, 'symfony/serializer')) ? 'defaultTrue' 'defaultFalse'}()->end()
  947.                         ->scalarNode('name_converter')->end()
  948.                         ->scalarNode('circular_reference_handler')->end()
  949.                         ->scalarNode('max_depth_handler')->end()
  950.                         ->arrayNode('mapping')
  951.                             ->addDefaultsIfNotSet()
  952.                             ->fixXmlConfig('path')
  953.                             ->children()
  954.                                 ->arrayNode('paths')
  955.                                     ->prototype('scalar')->end()
  956.                                 ->end()
  957.                             ->end()
  958.                         ->end()
  959.                         ->arrayNode('default_context')
  960.                             ->normalizeKeys(false)
  961.                             ->useAttributeAsKey('name')
  962.                             ->defaultValue([])
  963.                             ->prototype('variable')->end()
  964.                         ->end()
  965.                     ->end()
  966.                 ->end()
  967.             ->end()
  968.         ;
  969.     }
  970.     private function addPropertyAccessSection(ArrayNodeDefinition $rootNode, callable $willBeAvailable)
  971.     {
  972.         $rootNode
  973.             ->children()
  974.                 ->arrayNode('property_access')
  975.                     ->addDefaultsIfNotSet()
  976.                     ->info('Property access configuration')
  977.                     ->{$willBeAvailable('symfony/property-access'PropertyAccessor::class) ? 'canBeDisabled' 'canBeEnabled'}()
  978.                     ->children()
  979.                         ->booleanNode('magic_call')->defaultFalse()->end()
  980.                         ->booleanNode('magic_get')->defaultTrue()->end()
  981.                         ->booleanNode('magic_set')->defaultTrue()->end()
  982.                         ->booleanNode('throw_exception_on_invalid_index')->defaultFalse()->end()
  983.                         ->booleanNode('throw_exception_on_invalid_property_path')->defaultTrue()->end()
  984.                     ->end()
  985.                 ->end()
  986.             ->end()
  987.         ;
  988.     }
  989.     private function addPropertyInfoSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  990.     {
  991.         $rootNode
  992.             ->children()
  993.                 ->arrayNode('property_info')
  994.                     ->info('Property info configuration')
  995.                     ->{$enableIfStandalone('symfony/property-info'PropertyInfoExtractorInterface::class)}()
  996.                 ->end()
  997.             ->end()
  998.         ;
  999.     }
  1000.     private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBeAvailable)
  1001.     {
  1002.         $rootNode
  1003.             ->children()
  1004.                 ->arrayNode('cache')
  1005.                     ->info('Cache configuration')
  1006.                     ->addDefaultsIfNotSet()
  1007.                     ->fixXmlConfig('pool')
  1008.                     ->children()
  1009.                         ->scalarNode('prefix_seed')
  1010.                             ->info('Used to namespace cache keys when using several apps with the same shared backend')
  1011.                             ->defaultValue('_%kernel.project_dir%.%kernel.container_class%')
  1012.                             ->example('my-application-name/%kernel.environment%')
  1013.                         ->end()
  1014.                         ->scalarNode('app')
  1015.                             ->info('App related cache pools configuration')
  1016.                             ->defaultValue('cache.adapter.filesystem')
  1017.                         ->end()
  1018.                         ->scalarNode('system')
  1019.                             ->info('System related cache pools configuration')
  1020.                             ->defaultValue('cache.adapter.system')
  1021.                         ->end()
  1022.                         ->scalarNode('directory')->defaultValue('%kernel.cache_dir%/pools/app')->end()
  1023.                         ->scalarNode('default_doctrine_provider')->end()
  1024.                         ->scalarNode('default_psr6_provider')->end()
  1025.                         ->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end()
  1026.                         ->scalarNode('default_memcached_provider')->defaultValue('memcached://localhost')->end()
  1027.                         ->scalarNode('default_doctrine_dbal_provider')->defaultValue('database_connection')->end()
  1028.                         ->scalarNode('default_pdo_provider')->defaultValue($willBeAvailable('doctrine/dbal'Connection::class) && class_exists(DoctrineAdapter::class) ? 'database_connection' null)->end()
  1029.                         ->arrayNode('pools')
  1030.                             ->useAttributeAsKey('name')
  1031.                             ->prototype('array')
  1032.                                 ->fixXmlConfig('adapter')
  1033.                                 ->beforeNormalization()
  1034.                                     ->ifTrue(function ($v) { return isset($v['provider']) && \is_array($v['adapters'] ?? $v['adapter'] ?? null) && < \count($v['adapters'] ?? $v['adapter']); })
  1035.                                     ->thenInvalid('Pool cannot have a "provider" while more than one adapter is defined')
  1036.                                 ->end()
  1037.                                 ->children()
  1038.                                     ->arrayNode('adapters')
  1039.                                         ->performNoDeepMerging()
  1040.                                         ->info('One or more adapters to chain for creating the pool, defaults to "cache.app".')
  1041.                                         ->beforeNormalization()->castToArray()->end()
  1042.                                         ->beforeNormalization()
  1043.                                             ->always()->then(function ($values) {
  1044.                                                 if ([0] === array_keys($values) && \is_array($values[0])) {
  1045.                                                     return $values[0];
  1046.                                                 }
  1047.                                                 $adapters = [];
  1048.                                                 foreach ($values as $k => $v) {
  1049.                                                     if (\is_int($k) && \is_string($v)) {
  1050.                                                         $adapters[] = $v;
  1051.                                                     } elseif (!\is_array($v)) {
  1052.                                                         $adapters[$k] = $v;
  1053.                                                     } elseif (isset($v['provider'])) {
  1054.                                                         $adapters[$v['provider']] = $v['name'] ?? $v;
  1055.                                                     } else {
  1056.                                                         $adapters[] = $v['name'] ?? $v;
  1057.                                                     }
  1058.                                                 }
  1059.                                                 return $adapters;
  1060.                                             })
  1061.                                         ->end()
  1062.                                         ->prototype('scalar')->end()
  1063.                                     ->end()
  1064.                                     ->scalarNode('tags')->defaultNull()->end()
  1065.                                     ->booleanNode('public')->defaultFalse()->end()
  1066.                                     ->scalarNode('default_lifetime')
  1067.                                         ->info('Default lifetime of the pool')
  1068.                                         ->example('"300" for 5 minutes expressed in seconds, "PT5M" for five minutes expressed as ISO 8601 time interval, or "5 minutes" as a date expression')
  1069.                                     ->end()
  1070.                                     ->scalarNode('provider')
  1071.                                         ->info('Overwrite the setting from the default provider for this adapter.')
  1072.                                     ->end()
  1073.                                     ->scalarNode('early_expiration_message_bus')
  1074.                                         ->example('"messenger.default_bus" to send early expiration events to the default Messenger bus.')
  1075.                                     ->end()
  1076.                                     ->scalarNode('clearer')->end()
  1077.                                 ->end()
  1078.                             ->end()
  1079.                             ->validate()
  1080.                                 ->ifTrue(function ($v) { return isset($v['cache.app']) || isset($v['cache.system']); })
  1081.                                 ->thenInvalid('"cache.app" and "cache.system" are reserved names')
  1082.                             ->end()
  1083.                         ->end()
  1084.                     ->end()
  1085.                 ->end()
  1086.             ->end()
  1087.         ;
  1088.     }
  1089.     private function addPhpErrorsSection(ArrayNodeDefinition $rootNode)
  1090.     {
  1091.         $rootNode
  1092.             ->children()
  1093.                 ->arrayNode('php_errors')
  1094.                     ->info('PHP errors handling configuration')
  1095.                     ->addDefaultsIfNotSet()
  1096.                     ->children()
  1097.                         ->variableNode('log')
  1098.                             ->info('Use the application logger instead of the PHP logger for logging PHP errors.')
  1099.                             ->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants, or an array mapping E_* constants to log levels.')
  1100.                             ->defaultValue($this->debug)
  1101.                             ->treatNullLike($this->debug)
  1102.                             ->beforeNormalization()
  1103.                                 ->ifArray()
  1104.                                 ->then(function (array $v): array {
  1105.                                     if (!($v[0]['type'] ?? false)) {
  1106.                                         return $v;
  1107.                                     }
  1108.                                     // Fix XML normalization
  1109.                                     $ret = [];
  1110.                                     foreach ($v as ['type' => $type'logLevel' => $logLevel]) {
  1111.                                         $ret[$type] = $logLevel;
  1112.                                     }
  1113.                                     return $ret;
  1114.                                 })
  1115.                             ->end()
  1116.                             ->validate()
  1117.                                 ->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v) || \is_array($v)); })
  1118.                                 ->thenInvalid('The "php_errors.log" parameter should be either an integer, a boolean, or an array')
  1119.                             ->end()
  1120.                         ->end()
  1121.                         ->booleanNode('throw')
  1122.                             ->info('Throw PHP errors as \ErrorException instances.')
  1123.                             ->defaultValue($this->debug)
  1124.                             ->treatNullLike($this->debug)
  1125.                         ->end()
  1126.                     ->end()
  1127.                 ->end()
  1128.             ->end()
  1129.         ;
  1130.     }
  1131.     private function addExceptionsSection(ArrayNodeDefinition $rootNode)
  1132.     {
  1133.         $logLevels = (new \ReflectionClass(LogLevel::class))->getConstants();
  1134.         $rootNode
  1135.             ->fixXmlConfig('exception')
  1136.             ->children()
  1137.                 ->arrayNode('exceptions')
  1138.                     ->info('Exception handling configuration')
  1139.                     ->useAttributeAsKey('class')
  1140.                     ->beforeNormalization()
  1141.                         // Handle legacy XML configuration
  1142.                         ->ifArray()
  1143.                         ->then(function (array $v): array {
  1144.                             if (!\array_key_exists('exception'$v)) {
  1145.                                 return $v;
  1146.                             }
  1147.                             $v $v['exception'];
  1148.                             unset($v['exception']);
  1149.                             foreach ($v as &$exception) {
  1150.                                 $exception['class'] = $exception['name'];
  1151.                                 unset($exception['name']);
  1152.                             }
  1153.                             return $v;
  1154.                         })
  1155.                     ->end()
  1156.                     ->prototype('array')
  1157.                         ->children()
  1158.                             ->scalarNode('log_level')
  1159.                                 ->info('The level of log message. Null to let Symfony decide.')
  1160.                                 ->validate()
  1161.                                     ->ifTrue(function ($v) use ($logLevels) { return null !== $v && !\in_array($v$logLevelstrue); })
  1162.                                     ->thenInvalid(sprintf('The log level is not valid. Pick one among "%s".'implode('", "'$logLevels)))
  1163.                                 ->end()
  1164.                                 ->defaultNull()
  1165.                             ->end()
  1166.                             ->scalarNode('status_code')
  1167.                                 ->info('The status code of the response. Null or 0 to let Symfony decide.')
  1168.                                 ->beforeNormalization()
  1169.                                     ->ifTrue(function ($v) { return === $v; })
  1170.                                     ->then(function ($v) { return null; })
  1171.                                 ->end()
  1172.                                 ->validate()
  1173.                                     ->ifTrue(function ($v) { return null !== $v && ($v 100 || $v 599); })
  1174.                                     ->thenInvalid('The status code is not valid. Pick a value between 100 and 599.')
  1175.                                 ->end()
  1176.                                 ->defaultNull()
  1177.                             ->end()
  1178.                         ->end()
  1179.                     ->end()
  1180.                 ->end()
  1181.             ->end()
  1182.         ;
  1183.     }
  1184.     private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1185.     {
  1186.         $rootNode
  1187.             ->children()
  1188.                 ->arrayNode('lock')
  1189.                     ->info('Lock configuration')
  1190.                     ->{$enableIfStandalone('symfony/lock'Lock::class)}()
  1191.                     ->beforeNormalization()
  1192.                         ->ifString()->then(function ($v) { return ['enabled' => true'resources' => $v]; })
  1193.                     ->end()
  1194.                     ->beforeNormalization()
  1195.                         ->ifTrue(function ($v) { return \is_array($v) && !isset($v['enabled']); })
  1196.                         ->then(function ($v) { return $v + ['enabled' => true]; })
  1197.                     ->end()
  1198.                     ->beforeNormalization()
  1199.                         ->ifTrue(function ($v) { return \is_array($v) && !isset($v['resources']) && !isset($v['resource']); })
  1200.                         ->then(function ($v) {
  1201.                             $e $v['enabled'];
  1202.                             unset($v['enabled']);
  1203.                             return ['enabled' => $e'resources' => $v];
  1204.                         })
  1205.                     ->end()
  1206.                     ->addDefaultsIfNotSet()
  1207.                     ->validate()
  1208.                         ->ifTrue(static function (array $config) { return $config['enabled'] && !$config['resources']; })
  1209.                         ->thenInvalid('At least one resource must be defined.')
  1210.                     ->end()
  1211.                     ->fixXmlConfig('resource')
  1212.                     ->children()
  1213.                         ->arrayNode('resources')
  1214.                             ->normalizeKeys(false)
  1215.                             ->useAttributeAsKey('name')
  1216.                             ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' 'flock']])
  1217.                             ->beforeNormalization()
  1218.                                 ->ifString()->then(function ($v) { return ['default' => $v]; })
  1219.                             ->end()
  1220.                             ->beforeNormalization()
  1221.                                 ->ifTrue(function ($v) { return \is_array($v) && array_is_list($v); })
  1222.                                 ->then(function ($v) {
  1223.                                     $resources = [];
  1224.                                     foreach ($v as $resource) {
  1225.                                         $resources[] = \is_array($resource) && isset($resource['name'])
  1226.                                             ? [$resource['name'] => $resource['value']]
  1227.                                             : ['default' => $resource]
  1228.                                         ;
  1229.                                     }
  1230.                                     return array_merge_recursive([], ...$resources);
  1231.                                 })
  1232.                             ->end()
  1233.                             ->prototype('array')
  1234.                                 ->performNoDeepMerging()
  1235.                                 ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  1236.                                 ->prototype('scalar')->end()
  1237.                             ->end()
  1238.                         ->end()
  1239.                     ->end()
  1240.                 ->end()
  1241.             ->end()
  1242.         ;
  1243.     }
  1244.     private function addWebLinkSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1245.     {
  1246.         $rootNode
  1247.             ->children()
  1248.                 ->arrayNode('web_link')
  1249.                     ->info('web links configuration')
  1250.                     ->{$enableIfStandalone('symfony/weblink'HttpHeaderSerializer::class)}()
  1251.                 ->end()
  1252.             ->end()
  1253.         ;
  1254.     }
  1255.     private function addMessengerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1256.     {
  1257.         $rootNode
  1258.             ->children()
  1259.                 ->arrayNode('messenger')
  1260.                     ->info('Messenger configuration')
  1261.                     ->{$enableIfStandalone('symfony/messenger'MessageBusInterface::class)}()
  1262.                     ->fixXmlConfig('transport')
  1263.                     ->fixXmlConfig('bus''buses')
  1264.                     ->validate()
  1265.                         ->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > && null === $v['default_bus']; })
  1266.                         ->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
  1267.                     ->end()
  1268.                     ->validate()
  1269.                         ->ifTrue(static function ($v): bool { return isset($v['buses']) && null !== $v['default_bus'] && !isset($v['buses'][$v['default_bus']]); })
  1270.                         ->then(static function (array $v): void { throw new InvalidConfigurationException(sprintf('The specified default bus "%s" is not configured. Available buses are "%s".'$v['default_bus'], implode('", "'array_keys($v['buses'])))); })
  1271.                     ->end()
  1272.                     ->children()
  1273.                         ->arrayNode('routing')
  1274.                             ->normalizeKeys(false)
  1275.                             ->useAttributeAsKey('message_class')
  1276.                             ->beforeNormalization()
  1277.                                 ->always()
  1278.                                 ->then(function ($config) {
  1279.                                     if (!\is_array($config)) {
  1280.                                         return [];
  1281.                                     }
  1282.                                     // If XML config with only one routing attribute
  1283.                                     if (=== \count($config) && isset($config['message-class']) && isset($config['sender'])) {
  1284.                                         $config = [=> $config];
  1285.                                     }
  1286.                                     $newConfig = [];
  1287.                                     foreach ($config as $k => $v) {
  1288.                                         if (!\is_int($k)) {
  1289.                                             $newConfig[$k] = [
  1290.                                                 'senders' => $v['senders'] ?? (\is_array($v) ? array_values($v) : [$v]),
  1291.                                             ];
  1292.                                         } else {
  1293.                                             $newConfig[$v['message-class']]['senders'] = array_map(
  1294.                                                 function ($a) {
  1295.                                                     return \is_string($a) ? $a $a['service'];
  1296.                                                 },
  1297.                                                 array_values($v['sender'])
  1298.                                             );
  1299.                                         }
  1300.                                     }
  1301.                                     return $newConfig;
  1302.                                 })
  1303.                             ->end()
  1304.                             ->prototype('array')
  1305.                                 ->performNoDeepMerging()
  1306.                                 ->children()
  1307.                                     ->arrayNode('senders')
  1308.                                         ->requiresAtLeastOneElement()
  1309.                                         ->prototype('scalar')->end()
  1310.                                     ->end()
  1311.                                 ->end()
  1312.                             ->end()
  1313.                         ->end()
  1314.                         ->arrayNode('serializer')
  1315.                             ->addDefaultsIfNotSet()
  1316.                             ->children()
  1317.                                 ->scalarNode('default_serializer')
  1318.                                     ->defaultValue('messenger.transport.native_php_serializer')
  1319.                                     ->info('Service id to use as the default serializer for the transports.')
  1320.                                 ->end()
  1321.                                 ->arrayNode('symfony_serializer')
  1322.                                     ->addDefaultsIfNotSet()
  1323.                                     ->children()
  1324.                                         ->scalarNode('format')->defaultValue('json')->info('Serialization format for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')->end()
  1325.                                         ->arrayNode('context')
  1326.                                             ->normalizeKeys(false)
  1327.                                             ->useAttributeAsKey('name')
  1328.                                             ->defaultValue([])
  1329.                                             ->info('Context array for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')
  1330.                                             ->prototype('variable')->end()
  1331.                                         ->end()
  1332.                                     ->end()
  1333.                                 ->end()
  1334.                             ->end()
  1335.                         ->end()
  1336.                         ->arrayNode('transports')
  1337.                             ->normalizeKeys(false)
  1338.                             ->useAttributeAsKey('name')
  1339.                             ->arrayPrototype()
  1340.                                 ->beforeNormalization()
  1341.                                     ->ifString()
  1342.                                     ->then(function (string $dsn) {
  1343.                                         return ['dsn' => $dsn];
  1344.                                     })
  1345.                                 ->end()
  1346.                                 ->fixXmlConfig('option')
  1347.                                 ->children()
  1348.                                     ->scalarNode('dsn')->end()
  1349.                                     ->scalarNode('serializer')->defaultNull()->info('Service id of a custom serializer to use.')->end()
  1350.                                     ->arrayNode('options')
  1351.                                         ->normalizeKeys(false)
  1352.                                         ->defaultValue([])
  1353.                                         ->prototype('variable')
  1354.                                         ->end()
  1355.                                     ->end()
  1356.                                     ->scalarNode('failure_transport')
  1357.                                         ->defaultNull()
  1358.                                         ->info('Transport name to send failed messages to (after all retries have failed).')
  1359.                                     ->end()
  1360.                                     ->arrayNode('retry_strategy')
  1361.                                         ->addDefaultsIfNotSet()
  1362.                                         ->beforeNormalization()
  1363.                                             ->always(function ($v) {
  1364.                                                 if (isset($v['service']) && (isset($v['max_retries']) || isset($v['delay']) || isset($v['multiplier']) || isset($v['max_delay']))) {
  1365.                                                     throw new \InvalidArgumentException('The "service" cannot be used along with the other "retry_strategy" options.');
  1366.                                                 }
  1367.                                                 return $v;
  1368.                                             })
  1369.                                         ->end()
  1370.                                         ->children()
  1371.                                             ->scalarNode('service')->defaultNull()->info('Service id to override the retry strategy entirely')->end()
  1372.                                             ->integerNode('max_retries')->defaultValue(3)->min(0)->end()
  1373.                                             ->integerNode('delay')->defaultValue(1000)->min(0)->info('Time in ms to delay (or the initial value when multiplier is used)')->end()
  1374.                                             ->floatNode('multiplier')->defaultValue(2)->min(1)->info('If greater than 1, delay will grow exponentially for each retry: this delay = (delay * (multiple ^ retries))')->end()
  1375.                                             ->integerNode('max_delay')->defaultValue(0)->min(0)->info('Max time in ms that a retry should ever be delayed (0 = infinite)')->end()
  1376.                                         ->end()
  1377.                                     ->end()
  1378.                                 ->end()
  1379.                             ->end()
  1380.                         ->end()
  1381.                         ->scalarNode('failure_transport')
  1382.                             ->defaultNull()
  1383.                             ->info('Transport name to send failed messages to (after all retries have failed).')
  1384.                         ->end()
  1385.                         ->booleanNode('reset_on_message')
  1386.                             ->defaultNull()
  1387.                             ->info('Reset container services after each message.')
  1388.                         ->end()
  1389.                         ->scalarNode('default_bus')->defaultNull()->end()
  1390.                         ->arrayNode('buses')
  1391.                             ->defaultValue(['messenger.bus.default' => ['default_middleware' => true'middleware' => []]])
  1392.                             ->normalizeKeys(false)
  1393.                             ->useAttributeAsKey('name')
  1394.                             ->arrayPrototype()
  1395.                                 ->addDefaultsIfNotSet()
  1396.                                 ->children()
  1397.                                     ->enumNode('default_middleware')
  1398.                                         ->values([truefalse'allow_no_handlers'])
  1399.                                         ->defaultTrue()
  1400.                                     ->end()
  1401.                                     ->arrayNode('middleware')
  1402.                                         ->performNoDeepMerging()
  1403.                                         ->beforeNormalization()
  1404.                                             ->ifTrue(function ($v) { return \is_string($v) || (\is_array($v) && !\is_int(key($v))); })
  1405.                                             ->then(function ($v) { return [$v]; })
  1406.                                         ->end()
  1407.                                         ->defaultValue([])
  1408.                                         ->arrayPrototype()
  1409.                                             ->beforeNormalization()
  1410.                                                 ->always()
  1411.                                                 ->then(function ($middleware): array {
  1412.                                                     if (!\is_array($middleware)) {
  1413.                                                         return ['id' => $middleware];
  1414.                                                     }
  1415.                                                     if (isset($middleware['id'])) {
  1416.                                                         return $middleware;
  1417.                                                     }
  1418.                                                     if (< \count($middleware)) {
  1419.                                                         throw new \InvalidArgumentException('Invalid middleware at path "framework.messenger": a map with a single factory id as key and its arguments as value was expected, '.json_encode($middleware).' given.');
  1420.                                                     }
  1421.                                                     return [
  1422.                                                         'id' => key($middleware),
  1423.                                                         'arguments' => current($middleware),
  1424.                                                     ];
  1425.                                                 })
  1426.                                             ->end()
  1427.                                             ->fixXmlConfig('argument')
  1428.                                             ->children()
  1429.                                                 ->scalarNode('id')->isRequired()->cannotBeEmpty()->end()
  1430.                                                 ->arrayNode('arguments')
  1431.                                                     ->normalizeKeys(false)
  1432.                                                     ->defaultValue([])
  1433.                                                     ->prototype('variable')
  1434.                                                 ->end()
  1435.                                             ->end()
  1436.                                         ->end()
  1437.                                     ->end()
  1438.                                 ->end()
  1439.                             ->end()
  1440.                         ->end()
  1441.                     ->end()
  1442.                 ->end()
  1443.             ->end()
  1444.         ;
  1445.     }
  1446.     private function addRobotsIndexSection(ArrayNodeDefinition $rootNode)
  1447.     {
  1448.         $rootNode
  1449.             ->children()
  1450.                 ->booleanNode('disallow_search_engine_index')
  1451.                     ->info('Enabled by default when debug is enabled.')
  1452.                     ->defaultValue($this->debug)
  1453.                     ->treatNullLike($this->debug)
  1454.                 ->end()
  1455.             ->end()
  1456.         ;
  1457.     }
  1458.     private function addHttpClientSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1459.     {
  1460.         $rootNode
  1461.             ->children()
  1462.                 ->arrayNode('http_client')
  1463.                     ->info('HTTP Client configuration')
  1464.                     ->{$enableIfStandalone('symfony/http-client'HttpClient::class)}()
  1465.                     ->fixXmlConfig('scoped_client')
  1466.                     ->beforeNormalization()
  1467.                         ->always(function ($config) {
  1468.                             if (empty($config['scoped_clients']) || !\is_array($config['default_options']['retry_failed'] ?? null)) {
  1469.                                 return $config;
  1470.                             }
  1471.                             foreach ($config['scoped_clients'] as &$scopedConfig) {
  1472.                                 if (!isset($scopedConfig['retry_failed']) || true === $scopedConfig['retry_failed']) {
  1473.                                     $scopedConfig['retry_failed'] = $config['default_options']['retry_failed'];
  1474.                                     continue;
  1475.                                 }
  1476.                                 if (\is_array($scopedConfig['retry_failed'])) {
  1477.                                     $scopedConfig['retry_failed'] = $scopedConfig['retry_failed'] + $config['default_options']['retry_failed'];
  1478.                                 }
  1479.                             }
  1480.                             return $config;
  1481.                         })
  1482.                     ->end()
  1483.                     ->children()
  1484.                         ->integerNode('max_host_connections')
  1485.                             ->info('The maximum number of connections to a single host.')
  1486.                         ->end()
  1487.                         ->arrayNode('default_options')
  1488.                             ->fixXmlConfig('header')
  1489.                             ->children()
  1490.                                 ->arrayNode('headers')
  1491.                                     ->info('Associative array: header => value(s).')
  1492.                                     ->useAttributeAsKey('name')
  1493.                                     ->normalizeKeys(false)
  1494.                                     ->variablePrototype()->end()
  1495.                                 ->end()
  1496.                                 ->integerNode('max_redirects')
  1497.                                     ->info('The maximum number of redirects to follow.')
  1498.                                 ->end()
  1499.                                 ->scalarNode('http_version')
  1500.                                     ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1501.                                 ->end()
  1502.                                 ->arrayNode('resolve')
  1503.                                     ->info('Associative array: domain => IP.')
  1504.                                     ->useAttributeAsKey('host')
  1505.                                     ->beforeNormalization()
  1506.                                         ->always(function ($config) {
  1507.                                             if (!\is_array($config)) {
  1508.                                                 return [];
  1509.                                             }
  1510.                                             if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1511.                                                 return $config;
  1512.                                             }
  1513.                                             return [$config['host'] => $config['value']];
  1514.                                         })
  1515.                                     ->end()
  1516.                                     ->normalizeKeys(false)
  1517.                                     ->scalarPrototype()->end()
  1518.                                 ->end()
  1519.                                 ->scalarNode('proxy')
  1520.                                     ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1521.                                 ->end()
  1522.                                 ->scalarNode('no_proxy')
  1523.                                     ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1524.                                 ->end()
  1525.                                 ->floatNode('timeout')
  1526.                                     ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1527.                                 ->end()
  1528.                                 ->floatNode('max_duration')
  1529.                                     ->info('The maximum execution time for the request+response as a whole.')
  1530.                                 ->end()
  1531.                                 ->scalarNode('bindto')
  1532.                                     ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1533.                                 ->end()
  1534.                                 ->booleanNode('verify_peer')
  1535.                                     ->info('Indicates if the peer should be verified in an SSL/TLS context.')
  1536.                                 ->end()
  1537.                                 ->booleanNode('verify_host')
  1538.                                     ->info('Indicates if the host should exist as a certificate common name.')
  1539.                                 ->end()
  1540.                                 ->scalarNode('cafile')
  1541.                                     ->info('A certificate authority file.')
  1542.                                 ->end()
  1543.                                 ->scalarNode('capath')
  1544.                                     ->info('A directory that contains multiple certificate authority files.')
  1545.                                 ->end()
  1546.                                 ->scalarNode('local_cert')
  1547.                                     ->info('A PEM formatted certificate file.')
  1548.                                 ->end()
  1549.                                 ->scalarNode('local_pk')
  1550.                                     ->info('A private key file.')
  1551.                                 ->end()
  1552.                                 ->scalarNode('passphrase')
  1553.                                     ->info('The passphrase used to encrypt the "local_pk" file.')
  1554.                                 ->end()
  1555.                                 ->scalarNode('ciphers')
  1556.                                     ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1557.                                 ->end()
  1558.                                 ->arrayNode('peer_fingerprint')
  1559.                                     ->info('Associative array: hashing algorithm => hash(es).')
  1560.                                     ->normalizeKeys(false)
  1561.                                     ->children()
  1562.                                         ->variableNode('sha1')->end()
  1563.                                         ->variableNode('pin-sha256')->end()
  1564.                                         ->variableNode('md5')->end()
  1565.                                     ->end()
  1566.                                 ->end()
  1567.                                 ->append($this->addHttpClientRetrySection())
  1568.                             ->end()
  1569.                         ->end()
  1570.                         ->scalarNode('mock_response_factory')
  1571.                             ->info('The id of the service that should generate mock responses. It should be either an invokable or an iterable.')
  1572.                         ->end()
  1573.                         ->arrayNode('scoped_clients')
  1574.                             ->useAttributeAsKey('name')
  1575.                             ->normalizeKeys(false)
  1576.                             ->arrayPrototype()
  1577.                                 ->fixXmlConfig('header')
  1578.                                 ->beforeNormalization()
  1579.                                     ->always()
  1580.                                     ->then(function ($config) {
  1581.                                         if (!class_exists(HttpClient::class)) {
  1582.                                             throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
  1583.                                         }
  1584.                                         return \is_array($config) ? $config : ['base_uri' => $config];
  1585.                                     })
  1586.                                 ->end()
  1587.                                 ->validate()
  1588.                                     ->ifTrue(function ($v) { return !isset($v['scope']) && !isset($v['base_uri']); })
  1589.                                     ->thenInvalid('Either "scope" or "base_uri" should be defined.')
  1590.                                 ->end()
  1591.                                 ->validate()
  1592.                                     ->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); })
  1593.                                     ->thenInvalid('"query" applies to "base_uri" but no base URI is defined.')
  1594.                                 ->end()
  1595.                                 ->children()
  1596.                                     ->scalarNode('scope')
  1597.                                         ->info('The regular expression that the request URL must match before adding the other options. When none is provided, the base URI is used instead.')
  1598.                                         ->cannotBeEmpty()
  1599.                                     ->end()
  1600.                                     ->scalarNode('base_uri')
  1601.                                         ->info('The URI to resolve relative URLs, following rules in RFC 3985, section 2.')
  1602.                                         ->cannotBeEmpty()
  1603.                                     ->end()
  1604.                                     ->scalarNode('auth_basic')
  1605.                                         ->info('An HTTP Basic authentication "username:password".')
  1606.                                     ->end()
  1607.                                     ->scalarNode('auth_bearer')
  1608.                                         ->info('A token enabling HTTP Bearer authorization.')
  1609.                                     ->end()
  1610.                                     ->scalarNode('auth_ntlm')
  1611.                                         ->info('A "username:password" pair to use Microsoft NTLM authentication (requires the cURL extension).')
  1612.                                     ->end()
  1613.                                     ->arrayNode('query')
  1614.                                         ->info('Associative array of query string values merged with the base URI.')
  1615.                                         ->useAttributeAsKey('key')
  1616.                                         ->beforeNormalization()
  1617.                                             ->always(function ($config) {
  1618.                                                 if (!\is_array($config)) {
  1619.                                                     return [];
  1620.                                                 }
  1621.                                                 if (!isset($config['key'], $config['value']) || \count($config) > 2) {
  1622.                                                     return $config;
  1623.                                                 }
  1624.                                                 return [$config['key'] => $config['value']];
  1625.                                             })
  1626.                                         ->end()
  1627.                                         ->normalizeKeys(false)
  1628.                                         ->scalarPrototype()->end()
  1629.                                     ->end()
  1630.                                     ->arrayNode('headers')
  1631.                                         ->info('Associative array: header => value(s).')
  1632.                                         ->useAttributeAsKey('name')
  1633.                                         ->normalizeKeys(false)
  1634.                                         ->variablePrototype()->end()
  1635.                                     ->end()
  1636.                                     ->integerNode('max_redirects')
  1637.                                         ->info('The maximum number of redirects to follow.')
  1638.                                     ->end()
  1639.                                     ->scalarNode('http_version')
  1640.                                         ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1641.                                     ->end()
  1642.                                     ->arrayNode('resolve')
  1643.                                         ->info('Associative array: domain => IP.')
  1644.                                         ->useAttributeAsKey('host')
  1645.                                         ->beforeNormalization()
  1646.                                             ->always(function ($config) {
  1647.                                                 if (!\is_array($config)) {
  1648.                                                     return [];
  1649.                                                 }
  1650.                                                 if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1651.                                                     return $config;
  1652.                                                 }
  1653.                                                 return [$config['host'] => $config['value']];
  1654.                                             })
  1655.                                         ->end()
  1656.                                         ->normalizeKeys(false)
  1657.                                         ->scalarPrototype()->end()
  1658.                                     ->end()
  1659.                                     ->scalarNode('proxy')
  1660.                                         ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1661.                                     ->end()
  1662.                                     ->scalarNode('no_proxy')
  1663.                                         ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1664.                                     ->end()
  1665.                                     ->floatNode('timeout')
  1666.                                         ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1667.                                     ->end()
  1668.                                     ->floatNode('max_duration')
  1669.                                         ->info('The maximum execution time for the request+response as a whole.')
  1670.                                     ->end()
  1671.                                     ->scalarNode('bindto')
  1672.                                         ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1673.                                     ->end()
  1674.                                     ->booleanNode('verify_peer')
  1675.                                         ->info('Indicates if the peer should be verified in an SSL/TLS context.')
  1676.                                     ->end()
  1677.                                     ->booleanNode('verify_host')
  1678.                                         ->info('Indicates if the host should exist as a certificate common name.')
  1679.                                     ->end()
  1680.                                     ->scalarNode('cafile')
  1681.                                         ->info('A certificate authority file.')
  1682.                                     ->end()
  1683.                                     ->scalarNode('capath')
  1684.                                         ->info('A directory that contains multiple certificate authority files.')
  1685.                                     ->end()
  1686.                                     ->scalarNode('local_cert')
  1687.                                         ->info('A PEM formatted certificate file.')
  1688.                                     ->end()
  1689.                                     ->scalarNode('local_pk')
  1690.                                         ->info('A private key file.')
  1691.                                     ->end()
  1692.                                     ->scalarNode('passphrase')
  1693.                                         ->info('The passphrase used to encrypt the "local_pk" file.')
  1694.                                     ->end()
  1695.                                     ->scalarNode('ciphers')
  1696.                                         ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1697.                                     ->end()
  1698.                                     ->arrayNode('peer_fingerprint')
  1699.                                         ->info('Associative array: hashing algorithm => hash(es).')
  1700.                                         ->normalizeKeys(false)
  1701.                                         ->children()
  1702.                                             ->variableNode('sha1')->end()
  1703.                                             ->variableNode('pin-sha256')->end()
  1704.                                             ->variableNode('md5')->end()
  1705.                                         ->end()
  1706.                                     ->end()
  1707.                                     ->append($this->addHttpClientRetrySection())
  1708.                                 ->end()
  1709.                             ->end()
  1710.                         ->end()
  1711.                     ->end()
  1712.                 ->end()
  1713.             ->end()
  1714.         ;
  1715.     }
  1716.     private function addHttpClientRetrySection()
  1717.     {
  1718.         $root = new NodeBuilder();
  1719.         return $root
  1720.             ->arrayNode('retry_failed')
  1721.                 ->fixXmlConfig('http_code')
  1722.                 ->canBeEnabled()
  1723.                 ->addDefaultsIfNotSet()
  1724.                 ->beforeNormalization()
  1725.                     ->always(function ($v) {
  1726.                         if (isset($v['retry_strategy']) && (isset($v['http_codes']) || isset($v['delay']) || isset($v['multiplier']) || isset($v['max_delay']) || isset($v['jitter']))) {
  1727.                             throw new \InvalidArgumentException('The "retry_strategy" option cannot be used along with the "http_codes", "delay", "multiplier", "max_delay" or "jitter" options.');
  1728.                         }
  1729.                         return $v;
  1730.                     })
  1731.                 ->end()
  1732.                 ->children()
  1733.                     ->scalarNode('retry_strategy')->defaultNull()->info('service id to override the retry strategy')->end()
  1734.                     ->arrayNode('http_codes')
  1735.                         ->performNoDeepMerging()
  1736.                         ->beforeNormalization()
  1737.                             ->ifArray()
  1738.                             ->then(static function ($v) {
  1739.                                 $list = [];
  1740.                                 foreach ($v as $key => $val) {
  1741.                                     if (is_numeric($val)) {
  1742.                                         $list[] = ['code' => $val];
  1743.                                     } elseif (\is_array($val)) {
  1744.                                         if (isset($val['code']) || isset($val['methods'])) {
  1745.                                             $list[] = $val;
  1746.                                         } else {
  1747.                                             $list[] = ['code' => $key'methods' => $val];
  1748.                                         }
  1749.                                     } elseif (true === $val || null === $val) {
  1750.                                         $list[] = ['code' => $key];
  1751.                                     }
  1752.                                 }
  1753.                                 return $list;
  1754.                             })
  1755.                         ->end()
  1756.                         ->useAttributeAsKey('code')
  1757.                         ->arrayPrototype()
  1758.                             ->fixXmlConfig('method')
  1759.                             ->children()
  1760.                                 ->integerNode('code')->end()
  1761.                                 ->arrayNode('methods')
  1762.                                     ->beforeNormalization()
  1763.                                     ->ifArray()
  1764.                                         ->then(function ($v) {
  1765.                                             return array_map('strtoupper'$v);
  1766.                                         })
  1767.                                     ->end()
  1768.                                     ->prototype('scalar')->end()
  1769.                                     ->info('A list of HTTP methods that triggers a retry for this status code. When empty, all methods are retried')
  1770.                                 ->end()
  1771.                             ->end()
  1772.                         ->end()
  1773.                         ->info('A list of HTTP status code that triggers a retry')
  1774.                     ->end()
  1775.                     ->integerNode('max_retries')->defaultValue(3)->min(0)->end()
  1776.                     ->integerNode('delay')->defaultValue(1000)->min(0)->info('Time in ms to delay (or the initial value when multiplier is used)')->end()
  1777.                     ->floatNode('multiplier')->defaultValue(2)->min(1)->info('If greater than 1, delay will grow exponentially for each retry: delay * (multiple ^ retries)')->end()
  1778.                     ->integerNode('max_delay')->defaultValue(0)->min(0)->info('Max time in ms that a retry should ever be delayed (0 = infinite)')->end()
  1779.                     ->floatNode('jitter')->defaultValue(0.1)->min(0)->max(1)->info('Randomness in percent (between 0 and 1) to apply to the delay')->end()
  1780.                 ->end()
  1781.         ;
  1782.     }
  1783.     private function addMailerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1784.     {
  1785.         $rootNode
  1786.             ->children()
  1787.                 ->arrayNode('mailer')
  1788.                     ->info('Mailer configuration')
  1789.                     ->{$enableIfStandalone('symfony/mailer'Mailer::class)}()
  1790.                     ->validate()
  1791.                         ->ifTrue(function ($v) { return isset($v['dsn']) && \count($v['transports']); })
  1792.                         ->thenInvalid('"dsn" and "transports" cannot be used together.')
  1793.                     ->end()
  1794.                     ->fixXmlConfig('transport')
  1795.                     ->fixXmlConfig('header')
  1796.                     ->children()
  1797.                         ->scalarNode('message_bus')->defaultNull()->info('The message bus to use. Defaults to the default bus if the Messenger component is installed.')->end()
  1798.                         ->scalarNode('dsn')->defaultNull()->end()
  1799.                         ->arrayNode('transports')
  1800.                             ->useAttributeAsKey('name')
  1801.                             ->prototype('scalar')->end()
  1802.                         ->end()
  1803.                         ->arrayNode('envelope')
  1804.                             ->info('Mailer Envelope configuration')
  1805.                             ->children()
  1806.                                 ->scalarNode('sender')->end()
  1807.                                 ->arrayNode('recipients')
  1808.                                     ->performNoDeepMerging()
  1809.                                     ->beforeNormalization()
  1810.                                     ->ifArray()
  1811.                                         ->then(function ($v) {
  1812.                                             return array_filter(array_values($v));
  1813.                                         })
  1814.                                     ->end()
  1815.                                     ->prototype('scalar')->end()
  1816.                                 ->end()
  1817.                             ->end()
  1818.                         ->end()
  1819.                         ->arrayNode('headers')
  1820.                             ->normalizeKeys(false)
  1821.                             ->useAttributeAsKey('name')
  1822.                             ->prototype('array')
  1823.                                 ->normalizeKeys(false)
  1824.                                 ->beforeNormalization()
  1825.                                     ->ifTrue(function ($v) { return !\is_array($v) || array_keys($v) !== ['value']; })
  1826.                                     ->then(function ($v) { return ['value' => $v]; })
  1827.                                 ->end()
  1828.                                 ->children()
  1829.                                     ->variableNode('value')->end()
  1830.                                 ->end()
  1831.                             ->end()
  1832.                         ->end()
  1833.                     ->end()
  1834.                 ->end()
  1835.             ->end()
  1836.         ;
  1837.     }
  1838.     private function addNotifierSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1839.     {
  1840.         $rootNode
  1841.             ->children()
  1842.                 ->arrayNode('notifier')
  1843.                     ->info('Notifier configuration')
  1844.                     ->{$enableIfStandalone('symfony/notifier'Notifier::class)}()
  1845.                     ->fixXmlConfig('chatter_transport')
  1846.                     ->children()
  1847.                         ->arrayNode('chatter_transports')
  1848.                             ->useAttributeAsKey('name')
  1849.                             ->prototype('scalar')->end()
  1850.                         ->end()
  1851.                     ->end()
  1852.                     ->fixXmlConfig('texter_transport')
  1853.                     ->children()
  1854.                         ->arrayNode('texter_transports')
  1855.                             ->useAttributeAsKey('name')
  1856.                             ->prototype('scalar')->end()
  1857.                         ->end()
  1858.                     ->end()
  1859.                     ->children()
  1860.                         ->booleanNode('notification_on_failed_messages')->defaultFalse()->end()
  1861.                     ->end()
  1862.                     ->children()
  1863.                         ->arrayNode('channel_policy')
  1864.                             ->useAttributeAsKey('name')
  1865.                             ->prototype('array')
  1866.                                 ->beforeNormalization()->ifString()->then(function (string $v) { return [$v]; })->end()
  1867.                                 ->prototype('scalar')->end()
  1868.                             ->end()
  1869.                         ->end()
  1870.                     ->end()
  1871.                     ->fixXmlConfig('admin_recipient')
  1872.                     ->children()
  1873.                         ->arrayNode('admin_recipients')
  1874.                             ->prototype('array')
  1875.                                 ->children()
  1876.                                     ->scalarNode('email')->cannotBeEmpty()->end()
  1877.                                     ->scalarNode('phone')->defaultValue('')->end()
  1878.                                 ->end()
  1879.                             ->end()
  1880.                         ->end()
  1881.                     ->end()
  1882.                 ->end()
  1883.             ->end()
  1884.         ;
  1885.     }
  1886.     private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1887.     {
  1888.         $rootNode
  1889.             ->children()
  1890.                 ->arrayNode('rate_limiter')
  1891.                     ->info('Rate limiter configuration')
  1892.                     ->{$enableIfStandalone('symfony/rate-limiter'TokenBucketLimiter::class)}()
  1893.                     ->fixXmlConfig('limiter')
  1894.                     ->beforeNormalization()
  1895.                         ->ifTrue(function ($v) { return \is_array($v) && !isset($v['limiters']) && !isset($v['limiter']); })
  1896.                         ->then(function (array $v) {
  1897.                             $newV = [
  1898.                                 'enabled' => $v['enabled'] ?? true,
  1899.                             ];
  1900.                             unset($v['enabled']);
  1901.                             $newV['limiters'] = $v;
  1902.                             return $newV;
  1903.                         })
  1904.                     ->end()
  1905.                     ->children()
  1906.                         ->arrayNode('limiters')
  1907.                             ->useAttributeAsKey('name')
  1908.                             ->arrayPrototype()
  1909.                                 ->children()
  1910.                                     ->scalarNode('lock_factory')
  1911.                                         ->info('The service ID of the lock factory used by this limiter (or null to disable locking)')
  1912.                                         ->defaultValue('lock.factory')
  1913.                                     ->end()
  1914.                                     ->scalarNode('cache_pool')
  1915.                                         ->info('The cache pool to use for storing the current limiter state')
  1916.                                         ->defaultValue('cache.rate_limiter')
  1917.                                     ->end()
  1918.                                     ->scalarNode('storage_service')
  1919.                                         ->info('The service ID of a custom storage implementation, this precedes any configured "cache_pool"')
  1920.                                         ->defaultNull()
  1921.                                     ->end()
  1922.                                     ->enumNode('policy')
  1923.                                         ->info('The algorithm to be used by this limiter')
  1924.                                         ->isRequired()
  1925.                                         ->values(['fixed_window''token_bucket''sliding_window''no_limit'])
  1926.                                     ->end()
  1927.                                     ->integerNode('limit')
  1928.                                         ->info('The maximum allowed hits in a fixed interval or burst')
  1929.                                         ->isRequired()
  1930.                                     ->end()
  1931.                                     ->scalarNode('interval')
  1932.                                         ->info('Configures the fixed interval if "policy" is set to "fixed_window" or "sliding_window". The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent).')
  1933.                                     ->end()
  1934.                                     ->arrayNode('rate')
  1935.                                         ->info('Configures the fill rate if "policy" is set to "token_bucket"')
  1936.                                         ->children()
  1937.                                             ->scalarNode('interval')
  1938.                                                 ->info('Configures the rate interval. The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent).')
  1939.                                             ->end()
  1940.                                             ->integerNode('amount')->info('Amount of tokens to add each interval')->defaultValue(1)->end()
  1941.                                         ->end()
  1942.                                     ->end()
  1943.                                 ->end()
  1944.                             ->end()
  1945.                         ->end()
  1946.                     ->end()
  1947.                 ->end()
  1948.             ->end()
  1949.         ;
  1950.     }
  1951.     private function addUidSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
  1952.     {
  1953.         $rootNode
  1954.             ->children()
  1955.                 ->arrayNode('uid')
  1956.                     ->info('Uid configuration')
  1957.                     ->{$enableIfStandalone('symfony/uid'UuidFactory::class)}()
  1958.                     ->addDefaultsIfNotSet()
  1959.                     ->children()
  1960.                         ->enumNode('default_uuid_version')
  1961.                             ->defaultValue(6)
  1962.                             ->values([641])
  1963.                         ->end()
  1964.                         ->enumNode('name_based_uuid_version')
  1965.                             ->defaultValue(5)
  1966.                             ->values([53])
  1967.                         ->end()
  1968.                         ->scalarNode('name_based_uuid_namespace')
  1969.                             ->cannotBeEmpty()
  1970.                         ->end()
  1971.                         ->enumNode('time_based_uuid_version')
  1972.                             ->defaultValue(6)
  1973.                             ->values([61])
  1974.                         ->end()
  1975.                         ->scalarNode('time_based_uuid_node')
  1976.                             ->cannotBeEmpty()
  1977.                         ->end()
  1978.                     ->end()
  1979.                 ->end()
  1980.             ->end()
  1981.         ;
  1982.     }
  1983. }