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

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