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

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