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

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