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

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