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

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