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

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