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

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