Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

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

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