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

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\Cache\Cache;
  13. use Doctrine\DBAL\Connection;
  14. use Symfony\Bundle\FullStack;
  15. use Symfony\Component\Asset\Package;
  16. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  17. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  18. use Symfony\Component\Config\Definition\ConfigurationInterface;
  19. use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
  20. use Symfony\Component\DependencyInjection\Exception\LogicException;
  21. use Symfony\Component\Form\Form;
  22. use Symfony\Component\HttpClient\HttpClient;
  23. use Symfony\Component\HttpFoundation\Cookie;
  24. use Symfony\Component\Lock\Lock;
  25. use Symfony\Component\Lock\Store\SemaphoreStore;
  26. use Symfony\Component\Mailer\Mailer;
  27. use Symfony\Component\Messenger\MessageBusInterface;
  28. use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
  29. use Symfony\Component\Serializer\Serializer;
  30. use Symfony\Component\Translation\Translator;
  31. use Symfony\Component\Validator\Validation;
  32. use Symfony\Component\WebLink\HttpHeaderSerializer;
  33. /**
  34.  * FrameworkExtension configuration structure.
  35.  *
  36.  * @author Jeremy Mikola <jmikola@gmail.com>
  37.  * @author GrĂ©goire Pineau <lyrixx@lyrixx.info>
  38.  */
  39. class Configuration implements ConfigurationInterface
  40. {
  41.     private $debug;
  42.     /**
  43.      * @param bool $debug Whether debugging is enabled or not
  44.      */
  45.     public function __construct(bool $debug)
  46.     {
  47.         $this->debug $debug;
  48.     }
  49.     /**
  50.      * Generates the configuration tree builder.
  51.      *
  52.      * @return TreeBuilder The tree builder
  53.      */
  54.     public function getConfigTreeBuilder()
  55.     {
  56.         $treeBuilder = new TreeBuilder('framework');
  57.         $rootNode $treeBuilder->getRootNode();
  58.         $rootNode
  59.             ->beforeNormalization()
  60.                 ->ifTrue(function ($v) { return !isset($v['assets']) && isset($v['templating']) && class_exists(Package::class); })
  61.                 ->then(function ($v) {
  62.                     $v['assets'] = [];
  63.                     return $v;
  64.                 })
  65.             ->end()
  66.             ->children()
  67.                 ->scalarNode('secret')->end()
  68.                 ->scalarNode('http_method_override')
  69.                     ->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")
  70.                     ->defaultTrue()
  71.                 ->end()
  72.                 ->scalarNode('ide')->defaultNull()->end()
  73.                 ->booleanNode('test')->end()
  74.                 ->scalarNode('default_locale')->defaultValue('en')->end()
  75.                 ->arrayNode('trusted_hosts')
  76.                     ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  77.                     ->prototype('scalar')->end()
  78.                 ->end()
  79.                 ->scalarNode('error_controller')
  80.                     ->defaultValue('error_controller')
  81.                 ->end()
  82.             ->end()
  83.         ;
  84.         $this->addCsrfSection($rootNode);
  85.         $this->addFormSection($rootNode);
  86.         $this->addEsiSection($rootNode);
  87.         $this->addSsiSection($rootNode);
  88.         $this->addFragmentsSection($rootNode);
  89.         $this->addProfilerSection($rootNode);
  90.         $this->addWorkflowSection($rootNode);
  91.         $this->addRouterSection($rootNode);
  92.         $this->addSessionSection($rootNode);
  93.         $this->addRequestSection($rootNode);
  94.         $this->addTemplatingSection($rootNode);
  95.         $this->addAssetsSection($rootNode);
  96.         $this->addTranslatorSection($rootNode);
  97.         $this->addValidationSection($rootNode);
  98.         $this->addAnnotationsSection($rootNode);
  99.         $this->addSerializerSection($rootNode);
  100.         $this->addPropertyAccessSection($rootNode);
  101.         $this->addPropertyInfoSection($rootNode);
  102.         $this->addCacheSection($rootNode);
  103.         $this->addPhpErrorsSection($rootNode);
  104.         $this->addWebLinkSection($rootNode);
  105.         $this->addLockSection($rootNode);
  106.         $this->addMessengerSection($rootNode);
  107.         $this->addRobotsIndexSection($rootNode);
  108.         $this->addHttpClientSection($rootNode);
  109.         $this->addMailerSection($rootNode);
  110.         $this->addSecretsSection($rootNode);
  111.         return $treeBuilder;
  112.     }
  113.     private function addSecretsSection(ArrayNodeDefinition $rootNode)
  114.     {
  115.         $rootNode
  116.             ->children()
  117.                 ->arrayNode('secrets')
  118.                     ->canBeDisabled()
  119.                     ->children()
  120.                         ->scalarNode('vault_directory')->defaultValue('%kernel.project_dir%/config/secrets/%kernel.environment%')->cannotBeEmpty()->end()
  121.                         ->scalarNode('local_dotenv_file')->defaultValue('%kernel.project_dir%/.env.%kernel.environment%.local')->end()
  122.                         ->scalarNode('decryption_env_var')->defaultValue('base64:default::SYMFONY_DECRYPTION_SECRET')->end()
  123.                     ->end()
  124.                 ->end()
  125.             ->end()
  126.         ;
  127.     }
  128.     private function addCsrfSection(ArrayNodeDefinition $rootNode)
  129.     {
  130.         $rootNode
  131.             ->children()
  132.                 ->arrayNode('csrf_protection')
  133.                     ->treatFalseLike(['enabled' => false])
  134.                     ->treatTrueLike(['enabled' => true])
  135.                     ->treatNullLike(['enabled' => true])
  136.                     ->addDefaultsIfNotSet()
  137.                     ->children()
  138.                         // defaults to framework.session.enabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class)
  139.                         ->booleanNode('enabled')->defaultNull()->end()
  140.                     ->end()
  141.                 ->end()
  142.             ->end()
  143.         ;
  144.     }
  145.     private function addFormSection(ArrayNodeDefinition $rootNode)
  146.     {
  147.         $rootNode
  148.             ->children()
  149.                 ->arrayNode('form')
  150.                     ->info('form configuration')
  151.                     ->{!class_exists(FullStack::class) && class_exists(Form::class) ? 'canBeDisabled' 'canBeEnabled'}()
  152.                     ->children()
  153.                         ->arrayNode('csrf_protection')
  154.                             ->treatFalseLike(['enabled' => false])
  155.                             ->treatTrueLike(['enabled' => true])
  156.                             ->treatNullLike(['enabled' => true])
  157.                             ->addDefaultsIfNotSet()
  158.                             ->children()
  159.                                 ->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled
  160.                                 ->scalarNode('field_name')->defaultValue('_token')->end()
  161.                             ->end()
  162.                         ->end()
  163.                     ->end()
  164.                 ->end()
  165.             ->end()
  166.         ;
  167.     }
  168.     private function addEsiSection(ArrayNodeDefinition $rootNode)
  169.     {
  170.         $rootNode
  171.             ->children()
  172.                 ->arrayNode('esi')
  173.                     ->info('esi configuration')
  174.                     ->canBeEnabled()
  175.                 ->end()
  176.             ->end()
  177.         ;
  178.     }
  179.     private function addSsiSection(ArrayNodeDefinition $rootNode)
  180.     {
  181.         $rootNode
  182.             ->children()
  183.                 ->arrayNode('ssi')
  184.                     ->info('ssi configuration')
  185.                     ->canBeEnabled()
  186.                 ->end()
  187.             ->end();
  188.     }
  189.     private function addFragmentsSection(ArrayNodeDefinition $rootNode)
  190.     {
  191.         $rootNode
  192.             ->children()
  193.                 ->arrayNode('fragments')
  194.                     ->info('fragments configuration')
  195.                     ->canBeEnabled()
  196.                     ->children()
  197.                         ->scalarNode('hinclude_default_template')->defaultNull()->end()
  198.                         ->scalarNode('path')->defaultValue('/_fragment')->end()
  199.                     ->end()
  200.                 ->end()
  201.             ->end()
  202.         ;
  203.     }
  204.     private function addProfilerSection(ArrayNodeDefinition $rootNode)
  205.     {
  206.         $rootNode
  207.             ->children()
  208.                 ->arrayNode('profiler')
  209.                     ->info('profiler configuration')
  210.                     ->canBeEnabled()
  211.                     ->children()
  212.                         ->booleanNode('collect')->defaultTrue()->end()
  213.                         ->booleanNode('only_exceptions')->defaultFalse()->end()
  214.                         ->booleanNode('only_master_requests')->defaultFalse()->end()
  215.                         ->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end()
  216.                     ->end()
  217.                 ->end()
  218.             ->end()
  219.         ;
  220.     }
  221.     private function addWorkflowSection(ArrayNodeDefinition $rootNode)
  222.     {
  223.         $rootNode
  224.             ->fixXmlConfig('workflow')
  225.             ->children()
  226.                 ->arrayNode('workflows')
  227.                     ->canBeEnabled()
  228.                     ->beforeNormalization()
  229.                         ->always(function ($v) {
  230.                             if (\is_array($v) && true === $v['enabled']) {
  231.                                 $workflows $v;
  232.                                 unset($workflows['enabled']);
  233.                                 if (=== \count($workflows) && isset($workflows[0]['enabled']) && === \count($workflows[0])) {
  234.                                     $workflows = [];
  235.                                 }
  236.                                 if (=== \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail''type''marking_store''supports''support_strategy''initial_marking''places''transitions']))) {
  237.                                     $workflows $workflows['workflows'];
  238.                                 }
  239.                                 foreach ($workflows as $key => $workflow) {
  240.                                     if (isset($workflow['enabled']) && false === $workflow['enabled']) {
  241.                                         throw new LogicException(sprintf('Cannot disable a single workflow. Remove the configuration for the workflow "%s" instead.'$workflow['name']));
  242.                                     }
  243.                                     unset($workflows[$key]['enabled']);
  244.                                 }
  245.                                 $v = [
  246.                                     'enabled' => true,
  247.                                     'workflows' => $workflows,
  248.                                 ];
  249.                             }
  250.                             return $v;
  251.                         })
  252.                     ->end()
  253.                     ->children()
  254.                         ->arrayNode('workflows')
  255.                             ->useAttributeAsKey('name')
  256.                             ->prototype('array')
  257.                                 ->beforeNormalization()
  258.                                     ->always(function ($v) {
  259.                                         if (isset($v['initial_place'])) {
  260.                                             $v['initial_marking'] = [$v['initial_place']];
  261.                                         }
  262.                                         return $v;
  263.                                     })
  264.                                 ->end()
  265.                                 ->fixXmlConfig('support')
  266.                                 ->fixXmlConfig('place')
  267.                                 ->fixXmlConfig('transition')
  268.                                 ->children()
  269.                                     ->arrayNode('audit_trail')
  270.                                         ->canBeEnabled()
  271.                                     ->end()
  272.                                     ->enumNode('type')
  273.                                         ->values(['workflow''state_machine'])
  274.                                         ->defaultValue('state_machine')
  275.                                     ->end()
  276.                                     ->arrayNode('marking_store')
  277.                                         ->fixXmlConfig('argument')
  278.                                         ->children()
  279.                                             ->enumNode('type')
  280.                                                 ->values(['multiple_state''single_state''method'])
  281.                                                 ->validate()
  282.                                                     ->ifTrue(function ($v) { return 'method' !== $v; })
  283.                                                     ->then(function ($v) {
  284.                                                         @trigger_error('Passing something else than "method" has been deprecated in Symfony 4.3.', \E_USER_DEPRECATED);
  285.                                                         return $v;
  286.                                                     })
  287.                                                 ->end()
  288.                                             ->end()
  289.                                             ->arrayNode('arguments')
  290.                                                 ->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "property" instead.')
  291.                                                 ->beforeNormalization()
  292.                                                     ->ifString()
  293.                                                     ->then(function ($v) { return [$v]; })
  294.                                                 ->end()
  295.                                                 ->requiresAtLeastOneElement()
  296.                                                 ->prototype('scalar')
  297.                                                 ->end()
  298.                                             ->end()
  299.                                             ->scalarNode('property')
  300.                                                 ->defaultNull() // In Symfony 5.0, set "marking" as default property
  301.                                             ->end()
  302.                                             ->scalarNode('service')
  303.                                                 ->cannotBeEmpty()
  304.                                             ->end()
  305.                                         ->end()
  306.                                         ->validate()
  307.                                             ->ifTrue(function ($v) { return isset($v['type']) && isset($v['service']); })
  308.                                             ->thenInvalid('"type" and "service" cannot be used together.')
  309.                                         ->end()
  310.                                         ->validate()
  311.                                             ->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
  312.                                             ->thenInvalid('"arguments" and "service" cannot be used together.')
  313.                                         ->end()
  314.                                     ->end()
  315.                                     ->arrayNode('supports')
  316.                                         ->beforeNormalization()
  317.                                             ->ifString()
  318.                                             ->then(function ($v) { return [$v]; })
  319.                                         ->end()
  320.                                         ->prototype('scalar')
  321.                                             ->cannotBeEmpty()
  322.                                             ->validate()
  323.                                                 ->ifTrue(function ($v) { return !class_exists($v) && !interface_exists($vfalse); })
  324.                                                 ->thenInvalid('The supported class or interface "%s" does not exist.')
  325.                                             ->end()
  326.                                         ->end()
  327.                                     ->end()
  328.                                     ->scalarNode('support_strategy')
  329.                                         ->cannotBeEmpty()
  330.                                     ->end()
  331.                                     ->scalarNode('initial_place')
  332.                                         ->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead.')
  333.                                         ->defaultNull()
  334.                                     ->end()
  335.                                     ->arrayNode('initial_marking')
  336.                                         ->beforeNormalization()->castToArray()->end()
  337.                                         ->defaultValue([])
  338.                                         ->prototype('scalar')->end()
  339.                                     ->end()
  340.                                     ->arrayNode('places')
  341.                                         ->beforeNormalization()
  342.                                             ->always()
  343.                                             ->then(function ($places) {
  344.                                                 // It's an indexed array of shape  ['place1', 'place2']
  345.                                                 if (isset($places[0]) && \is_string($places[0])) {
  346.                                                     return array_map(function (string $place) {
  347.                                                         return ['name' => $place];
  348.                                                     }, $places);
  349.                                                 }
  350.                                                 // It's an indexed array, we let the validation occur
  351.                                                 if (isset($places[0]) && \is_array($places[0])) {
  352.                                                     return $places;
  353.                                                 }
  354.                                                 foreach ($places as $name => $place) {
  355.                                                     if (\is_array($place) && \array_key_exists('name'$place)) {
  356.                                                         continue;
  357.                                                     }
  358.                                                     $place['name'] = $name;
  359.                                                     $places[$name] = $place;
  360.                                                 }
  361.                                                 return array_values($places);
  362.                                             })
  363.                                         ->end()
  364.                                         ->isRequired()
  365.                                         ->requiresAtLeastOneElement()
  366.                                         ->prototype('array')
  367.                                             ->children()
  368.                                                 ->scalarNode('name')
  369.                                                     ->isRequired()
  370.                                                     ->cannotBeEmpty()
  371.                                                 ->end()
  372.                                                 ->arrayNode('metadata')
  373.                                                     ->normalizeKeys(false)
  374.                                                     ->defaultValue([])
  375.                                                     ->example(['color' => 'blue''description' => 'Workflow to manage article.'])
  376.                                                     ->prototype('variable')
  377.                                                     ->end()
  378.                                                 ->end()
  379.                                             ->end()
  380.                                         ->end()
  381.                                     ->end()
  382.                                     ->arrayNode('transitions')
  383.                                         ->beforeNormalization()
  384.                                             ->always()
  385.                                             ->then(function ($transitions) {
  386.                                                 // It's an indexed array, we let the validation occur
  387.                                                 if (isset($transitions[0]) && \is_array($transitions[0])) {
  388.                                                     return $transitions;
  389.                                                 }
  390.                                                 foreach ($transitions as $name => $transition) {
  391.                                                     if (\is_array($transition) && \array_key_exists('name'$transition)) {
  392.                                                         continue;
  393.                                                     }
  394.                                                     $transition['name'] = $name;
  395.                                                     $transitions[$name] = $transition;
  396.                                                 }
  397.                                                 return $transitions;
  398.                                             })
  399.                                         ->end()
  400.                                         ->isRequired()
  401.                                         ->requiresAtLeastOneElement()
  402.                                         ->prototype('array')
  403.                                             ->children()
  404.                                                 ->scalarNode('name')
  405.                                                     ->isRequired()
  406.                                                     ->cannotBeEmpty()
  407.                                                 ->end()
  408.                                                 ->scalarNode('guard')
  409.                                                     ->cannotBeEmpty()
  410.                                                     ->info('An expression to block the transition')
  411.                                                     ->example('is_fully_authenticated() and is_granted(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
  412.                                                 ->end()
  413.                                                 ->arrayNode('from')
  414.                                                     ->beforeNormalization()
  415.                                                         ->ifString()
  416.                                                         ->then(function ($v) { return [$v]; })
  417.                                                     ->end()
  418.                                                     ->requiresAtLeastOneElement()
  419.                                                     ->prototype('scalar')
  420.                                                         ->cannotBeEmpty()
  421.                                                     ->end()
  422.                                                 ->end()
  423.                                                 ->arrayNode('to')
  424.                                                     ->beforeNormalization()
  425.                                                         ->ifString()
  426.                                                         ->then(function ($v) { return [$v]; })
  427.                                                     ->end()
  428.                                                     ->requiresAtLeastOneElement()
  429.                                                     ->prototype('scalar')
  430.                                                         ->cannotBeEmpty()
  431.                                                     ->end()
  432.                                                 ->end()
  433.                                                 ->arrayNode('metadata')
  434.                                                     ->normalizeKeys(false)
  435.                                                     ->defaultValue([])
  436.                                                     ->example(['color' => 'blue''description' => 'Workflow to manage article.'])
  437.                                                     ->prototype('variable')
  438.                                                     ->end()
  439.                                                 ->end()
  440.                                             ->end()
  441.                                         ->end()
  442.                                     ->end()
  443.                                     ->arrayNode('metadata')
  444.                                         ->normalizeKeys(false)
  445.                                         ->defaultValue([])
  446.                                         ->example(['color' => 'blue''description' => 'Workflow to manage article.'])
  447.                                         ->prototype('variable')
  448.                                         ->end()
  449.                                     ->end()
  450.                                 ->end()
  451.                                 ->validate()
  452.                                     ->ifTrue(function ($v) {
  453.                                         return $v['supports'] && isset($v['support_strategy']);
  454.                                     })
  455.                                     ->thenInvalid('"supports" and "support_strategy" cannot be used together.')
  456.                                 ->end()
  457.                                 ->validate()
  458.                                     ->ifTrue(function ($v) {
  459.                                         return !$v['supports'] && !isset($v['support_strategy']);
  460.                                     })
  461.                                     ->thenInvalid('"supports" or "support_strategy" should be configured.')
  462.                                 ->end()
  463.                                 ->validate()
  464.                                     ->ifTrue(function ($v) {
  465.                                         return 'workflow' === $v['type'] && 'single_state' === ($v['marking_store']['type'] ?? false);
  466.                                     })
  467.                                     ->then(function ($v) {
  468.                                         @trigger_error('Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.', \E_USER_DEPRECATED);
  469.                                         return $v;
  470.                                     })
  471.                                 ->end()
  472.                                 ->validate()
  473.                                     ->ifTrue(function ($v) {
  474.                                         return isset($v['marking_store']['property'])
  475.                                             && (!isset($v['marking_store']['type']) || 'method' !== $v['marking_store']['type'])
  476.                                         ;
  477.                                     })
  478.                                     ->thenInvalid('"property" option is only supported by the "method" marking store.')
  479.                                 ->end()
  480.                             ->end()
  481.                         ->end()
  482.                     ->end()
  483.                 ->end()
  484.             ->end()
  485.         ;
  486.     }
  487.     private function addRouterSection(ArrayNodeDefinition $rootNode)
  488.     {
  489.         $rootNode
  490.             ->children()
  491.                 ->arrayNode('router')
  492.                     ->info('router configuration')
  493.                     ->canBeEnabled()
  494.                     ->children()
  495.                         ->scalarNode('resource')->isRequired()->end()
  496.                         ->scalarNode('type')->end()
  497.                         ->scalarNode('http_port')->defaultValue(80)->end()
  498.                         ->scalarNode('https_port')->defaultValue(443)->end()
  499.                         ->scalarNode('strict_requirements')
  500.                             ->info(
  501.                                 "set to true to throw an exception when a parameter does not match the requirements\n".
  502.                                 "set to false to disable exceptions when a parameter does not match the requirements (and return null instead)\n".
  503.                                 "set to null to disable parameter checks against requirements\n".
  504.                                 "'true' is the preferred configuration in development mode, while 'false' or 'null' might be preferred in production"
  505.                             )
  506.                             ->defaultTrue()
  507.                         ->end()
  508.                         ->booleanNode('utf8')->defaultFalse()->end()
  509.                     ->end()
  510.                 ->end()
  511.             ->end()
  512.         ;
  513.     }
  514.     private function addSessionSection(ArrayNodeDefinition $rootNode)
  515.     {
  516.         $rootNode
  517.             ->children()
  518.                 ->arrayNode('session')
  519.                     ->info('session configuration')
  520.                     ->canBeEnabled()
  521.                     ->children()
  522.                         ->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
  523.                         ->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
  524.                         ->scalarNode('name')
  525.                             ->validate()
  526.                                 ->ifTrue(function ($v) {
  527.                                     parse_str($v$parsed);
  528.                                     return implode('&'array_keys($parsed)) !== (string) $v;
  529.                                 })
  530.                                 ->thenInvalid('Session name %s contains illegal character(s)')
  531.                             ->end()
  532.                         ->end()
  533.                         ->scalarNode('cookie_lifetime')->end()
  534.                         ->scalarNode('cookie_path')->end()
  535.                         ->scalarNode('cookie_domain')->end()
  536.                         ->enumNode('cookie_secure')->values([truefalse'auto'])->end()
  537.                         ->booleanNode('cookie_httponly')->defaultTrue()->end()
  538.                         ->enumNode('cookie_samesite')->values([nullCookie::SAMESITE_LAXCookie::SAMESITE_STRICTCookie::SAMESITE_NONE])->defaultNull()->end()
  539.                         ->booleanNode('use_cookies')->end()
  540.                         ->scalarNode('gc_divisor')->end()
  541.                         ->scalarNode('gc_probability')->defaultValue(1)->end()
  542.                         ->scalarNode('gc_maxlifetime')->end()
  543.                         ->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end()
  544.                         ->integerNode('metadata_update_threshold')
  545.                             ->defaultValue(0)
  546.                             ->info('seconds to wait between 2 session metadata updates')
  547.                         ->end()
  548.                         ->integerNode('sid_length')
  549.                             ->min(22)
  550.                             ->max(256)
  551.                         ->end()
  552.                         ->integerNode('sid_bits_per_character')
  553.                             ->min(4)
  554.                             ->max(6)
  555.                         ->end()
  556.                     ->end()
  557.                 ->end()
  558.             ->end()
  559.         ;
  560.     }
  561.     private function addRequestSection(ArrayNodeDefinition $rootNode)
  562.     {
  563.         $rootNode
  564.             ->children()
  565.                 ->arrayNode('request')
  566.                     ->info('request configuration')
  567.                     ->canBeEnabled()
  568.                     ->fixXmlConfig('format')
  569.                     ->children()
  570.                         ->arrayNode('formats')
  571.                             ->useAttributeAsKey('name')
  572.                             ->prototype('array')
  573.                                 ->beforeNormalization()
  574.                                     ->ifTrue(function ($v) { return \is_array($v) && isset($v['mime_type']); })
  575.                                     ->then(function ($v) { return $v['mime_type']; })
  576.                                 ->end()
  577.                                 ->beforeNormalization()->castToArray()->end()
  578.                                 ->prototype('scalar')->end()
  579.                             ->end()
  580.                         ->end()
  581.                     ->end()
  582.                 ->end()
  583.             ->end()
  584.         ;
  585.     }
  586.     private function addTemplatingSection(ArrayNodeDefinition $rootNode)
  587.     {
  588.         $rootNode
  589.             ->children()
  590.                 ->arrayNode('templating')
  591.                     ->info('templating configuration')
  592.                     ->canBeEnabled()
  593.                     ->setDeprecated('The "%path%.%node%" configuration is deprecated since Symfony 4.3. Configure the "twig" section provided by the Twig Bundle instead.')
  594.                     ->beforeNormalization()
  595.                         ->ifTrue(function ($v) { return false === $v || \is_array($v) && false === $v['enabled']; })
  596.                         ->then(function () { return ['enabled' => false'engines' => false]; })
  597.                     ->end()
  598.                     ->children()
  599.                         ->scalarNode('hinclude_default_template')->setDeprecated('Setting "templating.hinclude_default_template" is deprecated since Symfony 4.3, use "fragments.hinclude_default_template" instead.')->defaultNull()->end()
  600.                         ->scalarNode('cache')->end()
  601.                         ->arrayNode('form')
  602.                             ->addDefaultsIfNotSet()
  603.                             ->fixXmlConfig('resource')
  604.                             ->children()
  605.                                 ->arrayNode('resources')
  606.                                     ->addDefaultChildrenIfNoneSet()
  607.                                     ->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
  608.                                     ->validate()
  609.                                         ->ifTrue(function ($v) {return !\in_array('FrameworkBundle:Form'$v); })
  610.                                         ->then(function ($v) {
  611.                                             return array_merge(['FrameworkBundle:Form'], $v);
  612.                                         })
  613.                                     ->end()
  614.                                 ->end()
  615.                             ->end()
  616.                         ->end()
  617.                     ->end()
  618.                     ->fixXmlConfig('engine')
  619.                     ->children()
  620.                         ->arrayNode('engines')
  621.                             ->example(['twig'])
  622.                             ->isRequired()
  623.                             ->requiresAtLeastOneElement()
  624.                             ->canBeUnset()
  625.                             ->beforeNormalization()
  626.                                 ->ifTrue(function ($v) { return !\is_array($v) && false !== $v; })
  627.                                 ->then(function ($v) { return [$v]; })
  628.                             ->end()
  629.                             ->prototype('scalar')->end()
  630.                         ->end()
  631.                     ->end()
  632.                     ->fixXmlConfig('loader')
  633.                     ->children()
  634.                         ->arrayNode('loaders')
  635.                             ->beforeNormalization()->castToArray()->end()
  636.                             ->prototype('scalar')->end()
  637.                         ->end()
  638.                     ->end()
  639.                 ->end()
  640.             ->end()
  641.         ;
  642.     }
  643.     private function addAssetsSection(ArrayNodeDefinition $rootNode)
  644.     {
  645.         $rootNode
  646.             ->children()
  647.                 ->arrayNode('assets')
  648.                     ->info('assets configuration')
  649.                     ->{!class_exists(FullStack::class) && class_exists(Package::class) ? 'canBeDisabled' 'canBeEnabled'}()
  650.                     ->fixXmlConfig('base_url')
  651.                     ->children()
  652.                         ->scalarNode('version_strategy')->defaultNull()->end()
  653.                         ->scalarNode('version')->defaultNull()->end()
  654.                         ->scalarNode('version_format')->defaultValue('%%s?%%s')->end()
  655.                         ->scalarNode('json_manifest_path')->defaultNull()->end()
  656.                         ->scalarNode('base_path')->defaultValue('')->end()
  657.                         ->arrayNode('base_urls')
  658.                             ->requiresAtLeastOneElement()
  659.                             ->beforeNormalization()->castToArray()->end()
  660.                             ->prototype('scalar')->end()
  661.                         ->end()
  662.                     ->end()
  663.                     ->validate()
  664.                         ->ifTrue(function ($v) {
  665.                             return isset($v['version_strategy']) && isset($v['version']);
  666.                         })
  667.                         ->thenInvalid('You cannot use both "version_strategy" and "version" at the same time under "assets".')
  668.                     ->end()
  669.                     ->validate()
  670.                         ->ifTrue(function ($v) {
  671.                             return isset($v['version_strategy']) && isset($v['json_manifest_path']);
  672.                         })
  673.                         ->thenInvalid('You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".')
  674.                     ->end()
  675.                     ->validate()
  676.                         ->ifTrue(function ($v) {
  677.                             return isset($v['version']) && isset($v['json_manifest_path']);
  678.                         })
  679.                         ->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets".')
  680.                     ->end()
  681.                     ->fixXmlConfig('package')
  682.                     ->children()
  683.                         ->arrayNode('packages')
  684.                             ->normalizeKeys(false)
  685.                             ->useAttributeAsKey('name')
  686.                             ->prototype('array')
  687.                                 ->fixXmlConfig('base_url')
  688.                                 ->children()
  689.                                     ->scalarNode('version_strategy')->defaultNull()->end()
  690.                                     ->scalarNode('version')
  691.                                         ->beforeNormalization()
  692.                                         ->ifTrue(function ($v) { return '' === $v; })
  693.                                         ->then(function ($v) { return; })
  694.                                         ->end()
  695.                                     ->end()
  696.                                     ->scalarNode('version_format')->defaultNull()->end()
  697.                                     ->scalarNode('json_manifest_path')->defaultNull()->end()
  698.                                     ->scalarNode('base_path')->defaultValue('')->end()
  699.                                     ->arrayNode('base_urls')
  700.                                         ->requiresAtLeastOneElement()
  701.                                         ->beforeNormalization()->castToArray()->end()
  702.                                         ->prototype('scalar')->end()
  703.                                     ->end()
  704.                                 ->end()
  705.                                 ->validate()
  706.                                     ->ifTrue(function ($v) {
  707.                                         return isset($v['version_strategy']) && isset($v['version']);
  708.                                     })
  709.                                     ->thenInvalid('You cannot use both "version_strategy" and "version" at the same time under "assets" packages.')
  710.                                 ->end()
  711.                                 ->validate()
  712.                                     ->ifTrue(function ($v) {
  713.                                         return isset($v['version_strategy']) && isset($v['json_manifest_path']);
  714.                                     })
  715.                                     ->thenInvalid('You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.')
  716.                                 ->end()
  717.                                 ->validate()
  718.                                     ->ifTrue(function ($v) {
  719.                                         return isset($v['version']) && isset($v['json_manifest_path']);
  720.                                     })
  721.                                     ->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.')
  722.                                 ->end()
  723.                             ->end()
  724.                         ->end()
  725.                     ->end()
  726.                 ->end()
  727.             ->end()
  728.         ;
  729.     }
  730.     private function addTranslatorSection(ArrayNodeDefinition $rootNode)
  731.     {
  732.         $rootNode
  733.             ->children()
  734.                 ->arrayNode('translator')
  735.                     ->info('translator configuration')
  736.                     ->{!class_exists(FullStack::class) && class_exists(Translator::class) ? 'canBeDisabled' 'canBeEnabled'}()
  737.                     ->fixXmlConfig('fallback')
  738.                     ->fixXmlConfig('path')
  739.                     ->children()
  740.                         ->arrayNode('fallbacks')
  741.                             ->info('Defaults to the value of "default_locale".')
  742.                             ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  743.                             ->prototype('scalar')->end()
  744.                             ->defaultValue([])
  745.                         ->end()
  746.                         ->booleanNode('logging')->defaultValue(false)->end()
  747.                         ->scalarNode('formatter')->defaultValue('translator.formatter.default')->end()
  748.                         ->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/translations')->end()
  749.                         ->scalarNode('default_path')
  750.                             ->info('The default path used to load translations')
  751.                             ->defaultValue('%kernel.project_dir%/translations')
  752.                         ->end()
  753.                         ->arrayNode('paths')
  754.                             ->prototype('scalar')->end()
  755.                         ->end()
  756.                     ->end()
  757.                 ->end()
  758.             ->end()
  759.         ;
  760.     }
  761.     private function addValidationSection(ArrayNodeDefinition $rootNode)
  762.     {
  763.         $rootNode
  764.             ->children()
  765.                 ->arrayNode('validation')
  766.                     ->info('validation configuration')
  767.                     ->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' 'canBeEnabled'}()
  768.                     ->validate()
  769.                         ->ifTrue(function ($v) { return isset($v['strict_email']) && isset($v['email_validation_mode']); })
  770.                         ->thenInvalid('"strict_email" and "email_validation_mode" cannot be used together.')
  771.                     ->end()
  772.                     ->beforeNormalization()
  773.                         ->ifTrue(function ($v) { return isset($v['strict_email']); })
  774.                         ->then(function ($v) {
  775.                             @trigger_error('The "framework.validation.strict_email" configuration key has been deprecated in Symfony 4.1. Use the "framework.validation.email_validation_mode" configuration key instead.', \E_USER_DEPRECATED);
  776.                             return $v;
  777.                         })
  778.                     ->end()
  779.                     ->beforeNormalization()
  780.                         ->ifTrue(function ($v) { return isset($v['strict_email']) && !isset($v['email_validation_mode']); })
  781.                         ->then(function ($v) {
  782.                             $v['email_validation_mode'] = $v['strict_email'] ? 'strict' 'loose';
  783.                             unset($v['strict_email']);
  784.                             return $v;
  785.                         })
  786.                     ->end()
  787.                     ->children()
  788.                         ->scalarNode('cache')->end()
  789.                         ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' 'defaultFalse'}()->end()
  790.                         ->arrayNode('static_method')
  791.                             ->defaultValue(['loadValidatorMetadata'])
  792.                             ->prototype('scalar')->end()
  793.                             ->treatFalseLike([])
  794.                             ->validate()->castToArray()->end()
  795.                         ->end()
  796.                         ->scalarNode('translation_domain')->defaultValue('validators')->end()
  797.                         ->booleanNode('strict_email')->end()
  798.                         ->enumNode('email_validation_mode')->values(['html5''loose''strict'])->end()
  799.                         ->arrayNode('mapping')
  800.                             ->addDefaultsIfNotSet()
  801.                             ->fixXmlConfig('path')
  802.                             ->children()
  803.                                 ->arrayNode('paths')
  804.                                     ->prototype('scalar')->end()
  805.                                 ->end()
  806.                             ->end()
  807.                         ->end()
  808.                         ->arrayNode('not_compromised_password')
  809.                             ->canBeDisabled()
  810.                             ->children()
  811.                                 ->booleanNode('enabled')
  812.                                     ->defaultTrue()
  813.                                     ->info('When disabled, compromised passwords will be accepted as valid.')
  814.                                 ->end()
  815.                                 ->scalarNode('endpoint')
  816.                                     ->defaultNull()
  817.                                     ->info('API endpoint for the NotCompromisedPassword Validator.')
  818.                                 ->end()
  819.                             ->end()
  820.                         ->end()
  821.                         ->arrayNode('auto_mapping')
  822.                             ->info('A collection of namespaces for which auto-mapping will be enabled by default, or null to opt-in with the EnableAutoMapping constraint.')
  823.                             ->example([
  824.                                 'App\\Entity\\' => [],
  825.                                 'App\\WithSpecificLoaders\\' => ['validator.property_info_loader'],
  826.                             ])
  827.                             ->useAttributeAsKey('namespace')
  828.                             ->normalizeKeys(false)
  829.                             ->beforeNormalization()
  830.                                 ->ifArray()
  831.                                 ->then(function (array $values): array {
  832.                                     foreach ($values as $k => $v) {
  833.                                         if (isset($v['service'])) {
  834.                                             continue;
  835.                                         }
  836.                                         if (isset($v['namespace'])) {
  837.                                             $values[$k]['services'] = [];
  838.                                             continue;
  839.                                         }
  840.                                         if (!\is_array($v)) {
  841.                                             $values[$v]['services'] = [];
  842.                                             unset($values[$k]);
  843.                                             continue;
  844.                                         }
  845.                                         $tmp $v;
  846.                                         unset($values[$k]);
  847.                                         $values[$k]['services'] = $tmp;
  848.                                     }
  849.                                     return $values;
  850.                                 })
  851.                             ->end()
  852.                             ->arrayPrototype()
  853.                                 ->fixXmlConfig('service')
  854.                                 ->children()
  855.                                     ->arrayNode('services')
  856.                                         ->prototype('scalar')->end()
  857.                                     ->end()
  858.                                 ->end()
  859.                             ->end()
  860.                         ->end()
  861.                     ->end()
  862.                 ->end()
  863.             ->end()
  864.         ;
  865.     }
  866.     private function addAnnotationsSection(ArrayNodeDefinition $rootNode)
  867.     {
  868.         $rootNode
  869.             ->children()
  870.                 ->arrayNode('annotations')
  871.                     ->info('annotation configuration')
  872.                     ->{class_exists(Annotation::class) ? 'canBeDisabled' 'canBeEnabled'}()
  873.                     ->children()
  874.                         ->scalarNode('cache')->defaultValue(interface_exists(Cache::class) ? 'php_array' 'none')->end()
  875.                         ->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
  876.                         ->booleanNode('debug')->defaultValue($this->debug)->end()
  877.                     ->end()
  878.                 ->end()
  879.             ->end()
  880.         ;
  881.     }
  882.     private function addSerializerSection(ArrayNodeDefinition $rootNode)
  883.     {
  884.         $rootNode
  885.             ->children()
  886.                 ->arrayNode('serializer')
  887.                     ->info('serializer configuration')
  888.                     ->{!class_exists(FullStack::class) && class_exists(Serializer::class) ? 'canBeDisabled' 'canBeEnabled'}()
  889.                     ->children()
  890.                         ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' 'defaultFalse'}()->end()
  891.                         ->scalarNode('name_converter')->end()
  892.                         ->scalarNode('circular_reference_handler')->end()
  893.                         ->scalarNode('max_depth_handler')->end()
  894.                         ->arrayNode('mapping')
  895.                             ->addDefaultsIfNotSet()
  896.                             ->fixXmlConfig('path')
  897.                             ->children()
  898.                                 ->arrayNode('paths')
  899.                                     ->prototype('scalar')->end()
  900.                                 ->end()
  901.                             ->end()
  902.                         ->end()
  903.                     ->end()
  904.                 ->end()
  905.             ->end()
  906.         ;
  907.     }
  908.     private function addPropertyAccessSection(ArrayNodeDefinition $rootNode)
  909.     {
  910.         $rootNode
  911.             ->children()
  912.                 ->arrayNode('property_access')
  913.                     ->addDefaultsIfNotSet()
  914.                     ->info('Property access configuration')
  915.                     ->children()
  916.                         ->booleanNode('magic_call')->defaultFalse()->end()
  917.                         ->booleanNode('throw_exception_on_invalid_index')->defaultFalse()->end()
  918.                         ->booleanNode('throw_exception_on_invalid_property_path')->defaultTrue()->end()
  919.                     ->end()
  920.                 ->end()
  921.             ->end()
  922.         ;
  923.     }
  924.     private function addPropertyInfoSection(ArrayNodeDefinition $rootNode)
  925.     {
  926.         $rootNode
  927.             ->children()
  928.                 ->arrayNode('property_info')
  929.                     ->info('Property info configuration')
  930.                     ->{!class_exists(FullStack::class) && interface_exists(PropertyInfoExtractorInterface::class) ? 'canBeDisabled' 'canBeEnabled'}()
  931.                 ->end()
  932.             ->end()
  933.         ;
  934.     }
  935.     private function addCacheSection(ArrayNodeDefinition $rootNode)
  936.     {
  937.         $rootNode
  938.             ->children()
  939.                 ->arrayNode('cache')
  940.                     ->info('Cache configuration')
  941.                     ->addDefaultsIfNotSet()
  942.                     ->fixXmlConfig('pool')
  943.                     ->children()
  944.                         ->scalarNode('prefix_seed')
  945.                             ->info('Used to namespace cache keys when using several apps with the same shared backend')
  946.                             ->example('my-application-name')
  947.                         ->end()
  948.                         ->scalarNode('app')
  949.                             ->info('App related cache pools configuration')
  950.                             ->defaultValue('cache.adapter.filesystem')
  951.                         ->end()
  952.                         ->scalarNode('system')
  953.                             ->info('System related cache pools configuration')
  954.                             ->defaultValue('cache.adapter.system')
  955.                         ->end()
  956.                         ->scalarNode('directory')->defaultValue('%kernel.cache_dir%/pools')->end()
  957.                         ->scalarNode('default_doctrine_provider')->end()
  958.                         ->scalarNode('default_psr6_provider')->end()
  959.                         ->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end()
  960.                         ->scalarNode('default_memcached_provider')->defaultValue('memcached://localhost')->end()
  961.                         ->scalarNode('default_pdo_provider')->defaultValue(class_exists(Connection::class) ? 'database_connection' null)->end()
  962.                         ->arrayNode('pools')
  963.                             ->useAttributeAsKey('name')
  964.                             ->prototype('array')
  965.                                 ->fixXmlConfig('adapter')
  966.                                 ->beforeNormalization()
  967.                                     ->ifTrue(function ($v) { return (isset($v['adapters']) || \is_array($v['adapter'] ?? null)) && isset($v['provider']); })
  968.                                     ->thenInvalid('Pool cannot have a "provider" while "adapter" is set to a map')
  969.                                 ->end()
  970.                                 ->children()
  971.                                     ->arrayNode('adapters')
  972.                                         ->performNoDeepMerging()
  973.                                         ->info('One or more adapters to chain for creating the pool, defaults to "cache.app".')
  974.                                         ->beforeNormalization()
  975.                                             ->always()->then(function ($values) {
  976.                                                 if ([0] === array_keys($values) && \is_array($values[0])) {
  977.                                                     return $values[0];
  978.                                                 }
  979.                                                 $adapters = [];
  980.                                                 foreach ($values as $k => $v) {
  981.                                                     if (\is_int($k) && \is_string($v)) {
  982.                                                         $adapters[] = $v;
  983.                                                     } elseif (!\is_array($v)) {
  984.                                                         $adapters[$k] = $v;
  985.                                                     } elseif (isset($v['provider'])) {
  986.                                                         $adapters[$v['provider']] = $v['name'] ?? $v;
  987.                                                     } else {
  988.                                                         $adapters[] = $v['name'] ?? $v;
  989.                                                     }
  990.                                                 }
  991.                                                 return $adapters;
  992.                                             })
  993.                                         ->end()
  994.                                         ->prototype('scalar')->end()
  995.                                     ->end()
  996.                                     ->scalarNode('tags')->defaultNull()->end()
  997.                                     ->booleanNode('public')->defaultFalse()->end()
  998.                                     ->integerNode('default_lifetime')->end()
  999.                                     ->scalarNode('provider')
  1000.                                         ->info('Overwrite the setting from the default provider for this adapter.')
  1001.                                     ->end()
  1002.                                     ->scalarNode('clearer')->end()
  1003.                                 ->end()
  1004.                             ->end()
  1005.                             ->validate()
  1006.                                 ->ifTrue(function ($v) { return isset($v['cache.app']) || isset($v['cache.system']); })
  1007.                                 ->thenInvalid('"cache.app" and "cache.system" are reserved names')
  1008.                             ->end()
  1009.                         ->end()
  1010.                     ->end()
  1011.                 ->end()
  1012.             ->end()
  1013.         ;
  1014.     }
  1015.     private function addPhpErrorsSection(ArrayNodeDefinition $rootNode)
  1016.     {
  1017.         $rootNode
  1018.             ->children()
  1019.                 ->arrayNode('php_errors')
  1020.                     ->info('PHP errors handling configuration')
  1021.                     ->addDefaultsIfNotSet()
  1022.                     ->children()
  1023.                         ->scalarNode('log')
  1024.                             ->info('Use the application logger instead of the PHP logger for logging PHP errors.')
  1025.                             ->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants.')
  1026.                             ->defaultValue($this->debug)
  1027.                             ->treatNullLike($this->debug)
  1028.                             ->validate()
  1029.                                 ->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); })
  1030.                                 ->thenInvalid('The "php_errors.log" parameter should be either an integer or a boolean.')
  1031.                             ->end()
  1032.                         ->end()
  1033.                         ->booleanNode('throw')
  1034.                             ->info('Throw PHP errors as \ErrorException instances.')
  1035.                             ->defaultValue($this->debug)
  1036.                             ->treatNullLike($this->debug)
  1037.                         ->end()
  1038.                     ->end()
  1039.                 ->end()
  1040.             ->end()
  1041.         ;
  1042.     }
  1043.     private function addLockSection(ArrayNodeDefinition $rootNode)
  1044.     {
  1045.         $rootNode
  1046.             ->children()
  1047.                 ->arrayNode('lock')
  1048.                     ->info('Lock configuration')
  1049.                     ->{!class_exists(FullStack::class) && class_exists(Lock::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1050.                     ->beforeNormalization()
  1051.                         ->ifString()->then(function ($v) { return ['enabled' => true'resources' => $v]; })
  1052.                     ->end()
  1053.                     ->beforeNormalization()
  1054.                         ->ifTrue(function ($v) { return \is_array($v) && !isset($v['enabled']); })
  1055.                         ->then(function ($v) { return $v + ['enabled' => true]; })
  1056.                     ->end()
  1057.                     ->beforeNormalization()
  1058.                         ->ifTrue(function ($v) { return \is_array($v) && !isset($v['resources']) && !isset($v['resource']); })
  1059.                         ->then(function ($v) {
  1060.                             $e $v['enabled'];
  1061.                             unset($v['enabled']);
  1062.                             return ['enabled' => $e'resources' => $v];
  1063.                         })
  1064.                     ->end()
  1065.                     ->addDefaultsIfNotSet()
  1066.                     ->fixXmlConfig('resource')
  1067.                     ->children()
  1068.                         ->arrayNode('resources')
  1069.                             ->requiresAtLeastOneElement()
  1070.                             ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' 'flock']])
  1071.                             ->beforeNormalization()
  1072.                                 ->ifString()->then(function ($v) { return ['default' => $v]; })
  1073.                             ->end()
  1074.                             ->beforeNormalization()
  1075.                                 ->ifTrue(function ($v) { return \is_array($v) && array_keys($v) === range(0, \count($v) - 1); })
  1076.                                 ->then(function ($v) {
  1077.                                     $resources = [];
  1078.                                     foreach ($v as $resource) {
  1079.                                         $resources array_merge_recursive(
  1080.                                             $resources,
  1081.                                             \is_array($resource) && isset($resource['name'])
  1082.                                                 ? [$resource['name'] => $resource['value']]
  1083.                                                 : ['default' => $resource]
  1084.                                         );
  1085.                                     }
  1086.                                     return $resources;
  1087.                                 })
  1088.                             ->end()
  1089.                             ->prototype('array')
  1090.                                 ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  1091.                                 ->prototype('scalar')->end()
  1092.                             ->end()
  1093.                         ->end()
  1094.                     ->end()
  1095.                 ->end()
  1096.             ->end()
  1097.         ;
  1098.     }
  1099.     private function addWebLinkSection(ArrayNodeDefinition $rootNode)
  1100.     {
  1101.         $rootNode
  1102.             ->children()
  1103.                 ->arrayNode('web_link')
  1104.                     ->info('web links configuration')
  1105.                     ->{!class_exists(FullStack::class) && class_exists(HttpHeaderSerializer::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1106.                 ->end()
  1107.             ->end()
  1108.         ;
  1109.     }
  1110.     private function addMessengerSection(ArrayNodeDefinition $rootNode)
  1111.     {
  1112.         $rootNode
  1113.             ->children()
  1114.                 ->arrayNode('messenger')
  1115.                     ->info('Messenger configuration')
  1116.                     ->{!class_exists(FullStack::class) && interface_exists(MessageBusInterface::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1117.                     ->fixXmlConfig('transport')
  1118.                     ->fixXmlConfig('bus''buses')
  1119.                     ->validate()
  1120.                         ->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > && null === $v['default_bus']; })
  1121.                         ->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
  1122.                     ->end()
  1123.                     ->validate()
  1124.                         ->ifTrue(static function ($v): bool { return isset($v['buses']) && null !== $v['default_bus'] && !isset($v['buses'][$v['default_bus']]); })
  1125.                         ->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'])))); })
  1126.                     ->end()
  1127.                     ->children()
  1128.                         ->arrayNode('routing')
  1129.                             ->normalizeKeys(false)
  1130.                             ->useAttributeAsKey('message_class')
  1131.                             ->beforeNormalization()
  1132.                                 ->always()
  1133.                                 ->then(function ($config) {
  1134.                                     if (!\is_array($config)) {
  1135.                                         return [];
  1136.                                     }
  1137.                                     // If XML config with only one routing attribute
  1138.                                     if (=== \count($config) && isset($config['message-class']) && isset($config['sender'])) {
  1139.                                         $config = [=> $config];
  1140.                                     }
  1141.                                     $newConfig = [];
  1142.                                     foreach ($config as $k => $v) {
  1143.                                         if (!\is_int($k)) {
  1144.                                             $newConfig[$k] = [
  1145.                                                 'senders' => $v['senders'] ?? (\is_array($v) ? array_values($v) : [$v]),
  1146.                                             ];
  1147.                                         } else {
  1148.                                             $newConfig[$v['message-class']]['senders'] = array_map(
  1149.                                                 function ($a) {
  1150.                                                     return \is_string($a) ? $a $a['service'];
  1151.                                                 },
  1152.                                                 array_values($v['sender'])
  1153.                                             );
  1154.                                         }
  1155.                                     }
  1156.                                     return $newConfig;
  1157.                                 })
  1158.                             ->end()
  1159.                             ->prototype('array')
  1160.                                 ->performNoDeepMerging()
  1161.                                 ->children()
  1162.                                     ->arrayNode('senders')
  1163.                                         ->requiresAtLeastOneElement()
  1164.                                         ->prototype('scalar')->end()
  1165.                                     ->end()
  1166.                                 ->end()
  1167.                             ->end()
  1168.                         ->end()
  1169.                         ->arrayNode('serializer')
  1170.                             ->addDefaultsIfNotSet()
  1171.                             ->children()
  1172.                                 ->scalarNode('default_serializer')
  1173.                                     ->defaultValue('messenger.transport.native_php_serializer')
  1174.                                     ->info('Service id to use as the default serializer for the transports.')
  1175.                                 ->end()
  1176.                                 ->arrayNode('symfony_serializer')
  1177.                                     ->addDefaultsIfNotSet()
  1178.                                     ->children()
  1179.                                         ->scalarNode('format')->defaultValue('json')->info('Serialization format for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')->end()
  1180.                                         ->arrayNode('context')
  1181.                                             ->normalizeKeys(false)
  1182.                                             ->useAttributeAsKey('name')
  1183.                                             ->defaultValue([])
  1184.                                             ->info('Context array for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')
  1185.                                             ->prototype('variable')->end()
  1186.                                         ->end()
  1187.                                     ->end()
  1188.                                 ->end()
  1189.                             ->end()
  1190.                         ->end()
  1191.                         ->arrayNode('transports')
  1192.                             ->normalizeKeys(false)
  1193.                             ->useAttributeAsKey('name')
  1194.                             ->arrayPrototype()
  1195.                                 ->beforeNormalization()
  1196.                                     ->ifString()
  1197.                                     ->then(function (string $dsn) {
  1198.                                         return ['dsn' => $dsn];
  1199.                                     })
  1200.                                 ->end()
  1201.                                 ->fixXmlConfig('option')
  1202.                                 ->children()
  1203.                                     ->scalarNode('dsn')->end()
  1204.                                     ->scalarNode('serializer')->defaultNull()->info('Service id of a custom serializer to use.')->end()
  1205.                                     ->arrayNode('options')
  1206.                                         ->normalizeKeys(false)
  1207.                                         ->defaultValue([])
  1208.                                         ->prototype('variable')
  1209.                                         ->end()
  1210.                                     ->end()
  1211.                                     ->arrayNode('retry_strategy')
  1212.                                         ->addDefaultsIfNotSet()
  1213.                                         ->beforeNormalization()
  1214.                                             ->always(function ($v) {
  1215.                                                 if (isset($v['service']) && (isset($v['max_retries']) || isset($v['delay']) || isset($v['multiplier']) || isset($v['max_delay']))) {
  1216.                                                     throw new \InvalidArgumentException('The "service" cannot be used along with the other "retry_strategy" options.');
  1217.                                                 }
  1218.                                                 return $v;
  1219.                                             })
  1220.                                         ->end()
  1221.                                         ->children()
  1222.                                             ->scalarNode('service')->defaultNull()->info('Service id to override the retry strategy entirely')->end()
  1223.                                             ->integerNode('max_retries')->defaultValue(3)->min(0)->end()
  1224.                                             ->integerNode('delay')->defaultValue(1000)->min(0)->info('Time in ms to delay (or the initial value when multiplier is used)')->end()
  1225.                                             ->floatNode('multiplier')->defaultValue(2)->min(1)->info('If greater than 1, delay will grow exponentially for each retry: this delay = (delay * (multiple ^ retries))')->end()
  1226.                                             ->integerNode('max_delay')->defaultValue(0)->min(0)->info('Max time in ms that a retry should ever be delayed (0 = infinite)')->end()
  1227.                                         ->end()
  1228.                                     ->end()
  1229.                                 ->end()
  1230.                             ->end()
  1231.                         ->end()
  1232.                         ->scalarNode('failure_transport')
  1233.                             ->defaultNull()
  1234.                             ->info('Transport name to send failed messages to (after all retries have failed).')
  1235.                         ->end()
  1236.                         ->scalarNode('default_bus')->defaultNull()->end()
  1237.                         ->arrayNode('buses')
  1238.                             ->defaultValue(['messenger.bus.default' => ['default_middleware' => true'middleware' => []]])
  1239.                             ->normalizeKeys(false)
  1240.                             ->useAttributeAsKey('name')
  1241.                             ->arrayPrototype()
  1242.                                 ->addDefaultsIfNotSet()
  1243.                                 ->children()
  1244.                                     ->enumNode('default_middleware')
  1245.                                         ->values([truefalse'allow_no_handlers'])
  1246.                                         ->defaultTrue()
  1247.                                     ->end()
  1248.                                     ->arrayNode('middleware')
  1249.                                         ->performNoDeepMerging()
  1250.                                         ->beforeNormalization()
  1251.                                             ->ifTrue(function ($v) { return \is_string($v) || (\is_array($v) && !\is_int(key($v))); })
  1252.                                             ->then(function ($v) { return [$v]; })
  1253.                                         ->end()
  1254.                                         ->defaultValue([])
  1255.                                         ->arrayPrototype()
  1256.                                             ->beforeNormalization()
  1257.                                                 ->always()
  1258.                                                 ->then(function ($middleware): array {
  1259.                                                     if (!\is_array($middleware)) {
  1260.                                                         return ['id' => $middleware];
  1261.                                                     }
  1262.                                                     if (isset($middleware['id'])) {
  1263.                                                         return $middleware;
  1264.                                                     }
  1265.                                                     if (< \count($middleware)) {
  1266.                                                         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.');
  1267.                                                     }
  1268.                                                     return [
  1269.                                                         'id' => key($middleware),
  1270.                                                         'arguments' => current($middleware),
  1271.                                                     ];
  1272.                                                 })
  1273.                                             ->end()
  1274.                                             ->fixXmlConfig('argument')
  1275.                                             ->children()
  1276.                                                 ->scalarNode('id')->isRequired()->cannotBeEmpty()->end()
  1277.                                                 ->arrayNode('arguments')
  1278.                                                     ->normalizeKeys(false)
  1279.                                                     ->defaultValue([])
  1280.                                                     ->prototype('variable')
  1281.                                                 ->end()
  1282.                                             ->end()
  1283.                                         ->end()
  1284.                                     ->end()
  1285.                                 ->end()
  1286.                             ->end()
  1287.                         ->end()
  1288.                     ->end()
  1289.                 ->end()
  1290.             ->end()
  1291.         ;
  1292.     }
  1293.     private function addRobotsIndexSection(ArrayNodeDefinition $rootNode)
  1294.     {
  1295.         $rootNode
  1296.             ->children()
  1297.                 ->booleanNode('disallow_search_engine_index')
  1298.                     ->info('Enabled by default when debug is enabled.')
  1299.                     ->defaultValue($this->debug)
  1300.                     ->treatNullLike($this->debug)
  1301.                 ->end()
  1302.             ->end()
  1303.         ;
  1304.     }
  1305.     private function addHttpClientSection(ArrayNodeDefinition $rootNode)
  1306.     {
  1307.         $rootNode
  1308.             ->children()
  1309.                 ->arrayNode('http_client')
  1310.                     ->info('HTTP Client configuration')
  1311.                     ->{!class_exists(FullStack::class) && class_exists(HttpClient::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1312.                     ->fixXmlConfig('scoped_client')
  1313.                     ->children()
  1314.                         ->integerNode('max_host_connections')
  1315.                             ->info('The maximum number of connections to a single host.')
  1316.                         ->end()
  1317.                         ->arrayNode('default_options')
  1318.                             ->fixXmlConfig('header')
  1319.                             ->children()
  1320.                                 ->arrayNode('headers')
  1321.                                     ->info('Associative array: header => value(s).')
  1322.                                     ->useAttributeAsKey('name')
  1323.                                     ->normalizeKeys(false)
  1324.                                     ->variablePrototype()->end()
  1325.                                 ->end()
  1326.                                 ->integerNode('max_redirects')
  1327.                                     ->info('The maximum number of redirects to follow.')
  1328.                                 ->end()
  1329.                                 ->scalarNode('http_version')
  1330.                                     ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1331.                                 ->end()
  1332.                                 ->arrayNode('resolve')
  1333.                                     ->info('Associative array: domain => IP.')
  1334.                                     ->useAttributeAsKey('host')
  1335.                                     ->beforeNormalization()
  1336.                                         ->always(function ($config) {
  1337.                                             if (!\is_array($config)) {
  1338.                                                 return [];
  1339.                                             }
  1340.                                             if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1341.                                                 return $config;
  1342.                                             }
  1343.                                             return [$config['host'] => $config['value']];
  1344.                                         })
  1345.                                     ->end()
  1346.                                     ->normalizeKeys(false)
  1347.                                     ->scalarPrototype()->end()
  1348.                                 ->end()
  1349.                                 ->scalarNode('proxy')
  1350.                                     ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1351.                                 ->end()
  1352.                                 ->scalarNode('no_proxy')
  1353.                                     ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1354.                                 ->end()
  1355.                                 ->floatNode('timeout')
  1356.                                     ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1357.                                 ->end()
  1358.                                 ->floatNode('max_duration')
  1359.                                     ->info('The maximum execution time for the request+response as a whole.')
  1360.                                 ->end()
  1361.                                 ->scalarNode('bindto')
  1362.                                     ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1363.                                 ->end()
  1364.                                 ->booleanNode('verify_peer')
  1365.                                     ->info('Indicates if the peer should be verified in a SSL/TLS context.')
  1366.                                 ->end()
  1367.                                 ->booleanNode('verify_host')
  1368.                                     ->info('Indicates if the host should exist as a certificate common name.')
  1369.                                 ->end()
  1370.                                 ->scalarNode('cafile')
  1371.                                     ->info('A certificate authority file.')
  1372.                                 ->end()
  1373.                                 ->scalarNode('capath')
  1374.                                     ->info('A directory that contains multiple certificate authority files.')
  1375.                                 ->end()
  1376.                                 ->scalarNode('local_cert')
  1377.                                     ->info('A PEM formatted certificate file.')
  1378.                                 ->end()
  1379.                                 ->scalarNode('local_pk')
  1380.                                     ->info('A private key file.')
  1381.                                 ->end()
  1382.                                 ->scalarNode('passphrase')
  1383.                                     ->info('The passphrase used to encrypt the "local_pk" file.')
  1384.                                 ->end()
  1385.                                 ->scalarNode('ciphers')
  1386.                                     ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1387.                                 ->end()
  1388.                                 ->arrayNode('peer_fingerprint')
  1389.                                     ->info('Associative array: hashing algorithm => hash(es).')
  1390.                                     ->normalizeKeys(false)
  1391.                                     ->children()
  1392.                                         ->variableNode('sha1')->end()
  1393.                                         ->variableNode('pin-sha256')->end()
  1394.                                         ->variableNode('md5')->end()
  1395.                                     ->end()
  1396.                                 ->end()
  1397.                             ->end()
  1398.                         ->end()
  1399.                         ->arrayNode('scoped_clients')
  1400.                             ->useAttributeAsKey('name')
  1401.                             ->normalizeKeys(false)
  1402.                             ->arrayPrototype()
  1403.                                 ->fixXmlConfig('header')
  1404.                                 ->beforeNormalization()
  1405.                                     ->always()
  1406.                                     ->then(function ($config) {
  1407.                                         if (!class_exists(HttpClient::class)) {
  1408.                                             throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
  1409.                                         }
  1410.                                         return \is_array($config) ? $config : ['base_uri' => $config];
  1411.                                     })
  1412.                                 ->end()
  1413.                                 ->validate()
  1414.                                     ->ifTrue(function ($v) { return !isset($v['scope']) && !isset($v['base_uri']); })
  1415.                                     ->thenInvalid('Either "scope" or "base_uri" should be defined.')
  1416.                                 ->end()
  1417.                                 ->validate()
  1418.                                     ->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); })
  1419.                                     ->thenInvalid('"query" applies to "base_uri" but no base URI is defined.')
  1420.                                 ->end()
  1421.                                 ->children()
  1422.                                     ->scalarNode('scope')
  1423.                                         ->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.')
  1424.                                         ->cannotBeEmpty()
  1425.                                     ->end()
  1426.                                     ->scalarNode('base_uri')
  1427.                                         ->info('The URI to resolve relative URLs, following rules in RFC 3985, section 2.')
  1428.                                         ->cannotBeEmpty()
  1429.                                     ->end()
  1430.                                     ->scalarNode('auth_basic')
  1431.                                         ->info('An HTTP Basic authentication "username:password".')
  1432.                                     ->end()
  1433.                                     ->scalarNode('auth_bearer')
  1434.                                         ->info('A token enabling HTTP Bearer authorization.')
  1435.                                     ->end()
  1436.                                     ->scalarNode('auth_ntlm')
  1437.                                         ->info('A "username:password" pair to use Microsoft NTLM authentication (requires the cURL extension).')
  1438.                                     ->end()
  1439.                                     ->arrayNode('query')
  1440.                                         ->info('Associative array of query string values merged with the base URI.')
  1441.                                         ->useAttributeAsKey('key')
  1442.                                         ->beforeNormalization()
  1443.                                             ->always(function ($config) {
  1444.                                                 if (!\is_array($config)) {
  1445.                                                     return [];
  1446.                                                 }
  1447.                                                 if (!isset($config['key'], $config['value']) || \count($config) > 2) {
  1448.                                                     return $config;
  1449.                                                 }
  1450.                                                 return [$config['key'] => $config['value']];
  1451.                                             })
  1452.                                         ->end()
  1453.                                         ->normalizeKeys(false)
  1454.                                         ->scalarPrototype()->end()
  1455.                                     ->end()
  1456.                                     ->arrayNode('headers')
  1457.                                         ->info('Associative array: header => value(s).')
  1458.                                         ->useAttributeAsKey('name')
  1459.                                         ->normalizeKeys(false)
  1460.                                         ->variablePrototype()->end()
  1461.                                     ->end()
  1462.                                     ->integerNode('max_redirects')
  1463.                                         ->info('The maximum number of redirects to follow.')
  1464.                                     ->end()
  1465.                                     ->scalarNode('http_version')
  1466.                                         ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1467.                                     ->end()
  1468.                                     ->arrayNode('resolve')
  1469.                                         ->info('Associative array: domain => IP.')
  1470.                                         ->useAttributeAsKey('host')
  1471.                                         ->beforeNormalization()
  1472.                                             ->always(function ($config) {
  1473.                                                 if (!\is_array($config)) {
  1474.                                                     return [];
  1475.                                                 }
  1476.                                                 if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1477.                                                     return $config;
  1478.                                                 }
  1479.                                                 return [$config['host'] => $config['value']];
  1480.                                             })
  1481.                                         ->end()
  1482.                                         ->normalizeKeys(false)
  1483.                                         ->scalarPrototype()->end()
  1484.                                     ->end()
  1485.                                     ->scalarNode('proxy')
  1486.                                         ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1487.                                     ->end()
  1488.                                     ->scalarNode('no_proxy')
  1489.                                         ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1490.                                     ->end()
  1491.                                     ->floatNode('timeout')
  1492.                                         ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1493.                                     ->end()
  1494.                                     ->floatNode('max_duration')
  1495.                                         ->info('The maximum execution time for the request+response as a whole.')
  1496.                                     ->end()
  1497.                                     ->scalarNode('bindto')
  1498.                                         ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1499.                                     ->end()
  1500.                                     ->booleanNode('verify_peer')
  1501.                                         ->info('Indicates if the peer should be verified in a SSL/TLS context.')
  1502.                                     ->end()
  1503.                                     ->booleanNode('verify_host')
  1504.                                         ->info('Indicates if the host should exist as a certificate common name.')
  1505.                                     ->end()
  1506.                                     ->scalarNode('cafile')
  1507.                                         ->info('A certificate authority file.')
  1508.                                     ->end()
  1509.                                     ->scalarNode('capath')
  1510.                                         ->info('A directory that contains multiple certificate authority files.')
  1511.                                     ->end()
  1512.                                     ->scalarNode('local_cert')
  1513.                                         ->info('A PEM formatted certificate file.')
  1514.                                     ->end()
  1515.                                     ->scalarNode('local_pk')
  1516.                                         ->info('A private key file.')
  1517.                                     ->end()
  1518.                                     ->scalarNode('passphrase')
  1519.                                         ->info('The passphrase used to encrypt the "local_pk" file.')
  1520.                                     ->end()
  1521.                                     ->scalarNode('ciphers')
  1522.                                         ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1523.                                     ->end()
  1524.                                     ->arrayNode('peer_fingerprint')
  1525.                                         ->info('Associative array: hashing algorithm => hash(es).')
  1526.                                         ->normalizeKeys(false)
  1527.                                         ->children()
  1528.                                             ->variableNode('sha1')->end()
  1529.                                             ->variableNode('pin-sha256')->end()
  1530.                                             ->variableNode('md5')->end()
  1531.                                         ->end()
  1532.                                     ->end()
  1533.                                 ->end()
  1534.                             ->end()
  1535.                         ->end()
  1536.                     ->end()
  1537.                 ->end()
  1538.             ->end()
  1539.         ;
  1540.     }
  1541.     private function addMailerSection(ArrayNodeDefinition $rootNode)
  1542.     {
  1543.         $rootNode
  1544.             ->children()
  1545.                 ->arrayNode('mailer')
  1546.                     ->info('Mailer configuration')
  1547.                     ->{!class_exists(FullStack::class) && class_exists(Mailer::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1548.                     ->validate()
  1549.                         ->ifTrue(function ($v) { return isset($v['dsn']) && \count($v['transports']); })
  1550.                         ->thenInvalid('"dsn" and "transports" cannot be used together.')
  1551.                     ->end()
  1552.                     ->fixXmlConfig('transport')
  1553.                     ->children()
  1554.                         ->scalarNode('dsn')->defaultNull()->end()
  1555.                         ->arrayNode('transports')
  1556.                             ->useAttributeAsKey('name')
  1557.                             ->prototype('scalar')->end()
  1558.                         ->end()
  1559.                         ->arrayNode('envelope')
  1560.                             ->info('Mailer Envelope configuration')
  1561.                             ->children()
  1562.                                 ->scalarNode('sender')->end()
  1563.                                 ->arrayNode('recipients')
  1564.                                     ->performNoDeepMerging()
  1565.                                     ->beforeNormalization()
  1566.                                     ->ifArray()
  1567.                                         ->then(function ($v) {
  1568.                                             return array_filter(array_values($v));
  1569.                                         })
  1570.                                     ->end()
  1571.                                     ->prototype('scalar')->end()
  1572.                                 ->end()
  1573.                             ->end()
  1574.                         ->end()
  1575.                     ->end()
  1576.                 ->end()
  1577.             ->end()
  1578.         ;
  1579.     }
  1580. }