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 <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
  11. use Doctrine\Common\Annotations\Annotation;
  12. use Doctrine\Common\Cache\Cache;
  13. use Doctrine\DBAL\Connection;
  14. use Symfony\Bundle\FullStack;
  15. use Symfony\Component\Asset\Package;
  16. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  17. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  18. use Symfony\Component\Config\Definition\ConfigurationInterface;
  19. use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
  20. use Symfony\Component\DependencyInjection\Exception\LogicException;
  21. use Symfony\Component\Form\Form;
  22. use Symfony\Component\HttpClient\HttpClient;
  23. use Symfony\Component\HttpFoundation\Cookie;
  24. use Symfony\Component\Lock\Lock;
  25. use Symfony\Component\Lock\Store\SemaphoreStore;
  26. use Symfony\Component\Mailer\Mailer;
  27. use Symfony\Component\Messenger\MessageBusInterface;
  28. use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
  29. use Symfony\Component\Serializer\Serializer;
  30. use Symfony\Component\Translation\Translator;
  31. use Symfony\Component\Validator\Validation;
  32. use Symfony\Component\WebLink\HttpHeaderSerializer;
  33. /**
  34.  * FrameworkExtension configuration structure.
  35.  */
  36. 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.                     ->fixXmlConfig('resource')
  1065.                     ->children()
  1066.                         ->arrayNode('resources')
  1067.                             ->normalizeKeys(false)
  1068.                             ->useAttributeAsKey('name')
  1069.                             ->requiresAtLeastOneElement()
  1070.                             ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' 'flock']])
  1071.                             ->beforeNormalization()
  1072.                                 ->ifString()->then(function ($v) { return ['default' => $v]; })
  1073.                             ->end()
  1074.                             ->beforeNormalization()
  1075.                                 ->ifTrue(function ($v) { return \is_array($v) && array_keys($v) === range(0, \count($v) - 1); })
  1076.                                 ->then(function ($v) {
  1077.                                     $resources = [];
  1078.                                     foreach ($v as $resource) {
  1079.                                         $resources array_merge_recursive(
  1080.                                             $resources,
  1081.                                             \is_array($resource) && isset($resource['name'])
  1082.                                                 ? [$resource['name'] => $resource['value']]
  1083.                                                 : ['default' => $resource]
  1084.                                         );
  1085.                                     }
  1086.                                     return $resources;
  1087.                                 })
  1088.                             ->end()
  1089.                             ->prototype('array')
  1090.                                 ->performNoDeepMerging()
  1091.                                 ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  1092.                                 ->prototype('scalar')->end()
  1093.                             ->end()
  1094.                         ->end()
  1095.                     ->end()
  1096.                 ->end()
  1097.             ->end()
  1098.         ;
  1099.     }
  1100.     private function addWebLinkSection(ArrayNodeDefinition $rootNode)
  1101.     {
  1102.         $rootNode
  1103.             ->children()
  1104.                 ->arrayNode('web_link')
  1105.                     ->info('web links configuration')
  1106.                     ->{!class_exists(FullStack::class) && class_exists(HttpHeaderSerializer::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1107.                 ->end()
  1108.             ->end()
  1109.         ;
  1110.     }
  1111.     private function addMessengerSection(ArrayNodeDefinition $rootNode)
  1112.     {
  1113.         $rootNode
  1114.             ->children()
  1115.                 ->arrayNode('messenger')
  1116.                     ->info('Messenger configuration')
  1117.                     ->{!class_exists(FullStack::class) && interface_exists(MessageBusInterface::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1118.                     ->fixXmlConfig('transport')
  1119.                     ->fixXmlConfig('bus''buses')
  1120.                     ->validate()
  1121.                         ->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > && null === $v['default_bus']; })
  1122.                         ->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
  1123.                     ->end()
  1124.                     ->validate()
  1125.                         ->ifTrue(static function ($v): bool { return isset($v['buses']) && null !== $v['default_bus'] && !isset($v['buses'][$v['default_bus']]); })
  1126.                         ->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'])))); })
  1127.                     ->end()
  1128.                     ->children()
  1129.                         ->arrayNode('routing')
  1130.                             ->normalizeKeys(false)
  1131.                             ->useAttributeAsKey('message_class')
  1132.                             ->beforeNormalization()
  1133.                                 ->always()
  1134.                                 ->then(function ($config) {
  1135.                                     if (!\is_array($config)) {
  1136.                                         return [];
  1137.                                     }
  1138.                                     // If XML config with only one routing attribute
  1139.                                     if (=== \count($config) && isset($config['message-class']) && isset($config['sender'])) {
  1140.                                         $config = [=> $config];
  1141.                                     }
  1142.                                     $newConfig = [];
  1143.                                     foreach ($config as $k => $v) {
  1144.                                         if (!\is_int($k)) {
  1145.                                             $newConfig[$k] = [
  1146.                                                 'senders' => $v['senders'] ?? (\is_array($v) ? array_values($v) : [$v]),
  1147.                                             ];
  1148.                                         } else {
  1149.                                             $newConfig[$v['message-class']]['senders'] = array_map(
  1150.                                                 function ($a) {
  1151.                                                     return \is_string($a) ? $a $a['service'];
  1152.                                                 },
  1153.                                                 array_values($v['sender'])
  1154.                                             );
  1155.                                         }
  1156.                                     }
  1157.                                     return $newConfig;
  1158.                                 })
  1159.                             ->end()
  1160.                             ->prototype('array')
  1161.                                 ->performNoDeepMerging()
  1162.                                 ->children()
  1163.                                     ->arrayNode('senders')
  1164.                                         ->requiresAtLeastOneElement()
  1165.                                         ->prototype('scalar')->end()
  1166.                                     ->end()
  1167.                                 ->end()
  1168.                             ->end()
  1169.                         ->end()
  1170.                         ->arrayNode('serializer')
  1171.                             ->addDefaultsIfNotSet()
  1172.                             ->children()
  1173.                                 ->scalarNode('default_serializer')
  1174.                                     ->defaultValue('messenger.transport.native_php_serializer')
  1175.                                     ->info('Service id to use as the default serializer for the transports.')
  1176.                                 ->end()
  1177.                                 ->arrayNode('symfony_serializer')
  1178.                                     ->addDefaultsIfNotSet()
  1179.                                     ->children()
  1180.                                         ->scalarNode('format')->defaultValue('json')->info('Serialization format for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')->end()
  1181.                                         ->arrayNode('context')
  1182.                                             ->normalizeKeys(false)
  1183.                                             ->useAttributeAsKey('name')
  1184.                                             ->defaultValue([])
  1185.                                             ->info('Context array for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')
  1186.                                             ->prototype('variable')->end()
  1187.                                         ->end()
  1188.                                     ->end()
  1189.                                 ->end()
  1190.                             ->end()
  1191.                         ->end()
  1192.                         ->arrayNode('transports')
  1193.                             ->normalizeKeys(false)
  1194.                             ->useAttributeAsKey('name')
  1195.                             ->arrayPrototype()
  1196.                                 ->beforeNormalization()
  1197.                                     ->ifString()
  1198.                                     ->then(function (string $dsn) {
  1199.                                         return ['dsn' => $dsn];
  1200.                                     })
  1201.                                 ->end()
  1202.                                 ->fixXmlConfig('option')
  1203.                                 ->children()
  1204.                                     ->scalarNode('dsn')->end()
  1205.                                     ->scalarNode('serializer')->defaultNull()->info('Service id of a custom serializer to use.')->end()
  1206.                                     ->arrayNode('options')
  1207.                                         ->normalizeKeys(false)
  1208.                                         ->defaultValue([])
  1209.                                         ->prototype('variable')
  1210.                                         ->end()
  1211.                                     ->end()
  1212.                                     ->arrayNode('retry_strategy')
  1213.                                         ->addDefaultsIfNotSet()
  1214.                                         ->beforeNormalization()
  1215.                                             ->always(function ($v) {
  1216.                                                 if (isset($v['service']) && (isset($v['max_retries']) || isset($v['delay']) || isset($v['multiplier']) || isset($v['max_delay']))) {
  1217.                                                     throw new \InvalidArgumentException('The "service" cannot be used along with the other "retry_strategy" options.');
  1218.                                                 }
  1219.                                                 return $v;
  1220.                                             })
  1221.                                         ->end()
  1222.                                         ->children()
  1223.                                             ->scalarNode('service')->defaultNull()->info('Service id to override the retry strategy entirely')->end()
  1224.                                             ->integerNode('max_retries')->defaultValue(3)->min(0)->end()
  1225.                                             ->integerNode('delay')->defaultValue(1000)->min(0)->info('Time in ms to delay (or the initial value when multiplier is used)')->end()
  1226.                                             ->floatNode('multiplier')->defaultValue(2)->min(1)->info('If greater than 1, delay will grow exponentially for each retry: this delay = (delay * (multiple ^ retries))')->end()
  1227.                                             ->integerNode('max_delay')->defaultValue(0)->min(0)->info('Max time in ms that a retry should ever be delayed (0 = infinite)')->end()
  1228.                                         ->end()
  1229.                                     ->end()
  1230.                                 ->end()
  1231.                             ->end()
  1232.                         ->end()
  1233.                         ->scalarNode('failure_transport')
  1234.                             ->defaultNull()
  1235.                             ->info('Transport name to send failed messages to (after all retries have failed).')
  1236.                         ->end()
  1237.                         ->scalarNode('default_bus')->defaultNull()->end()
  1238.                         ->arrayNode('buses')
  1239.                             ->defaultValue(['messenger.bus.default' => ['default_middleware' => true'middleware' => []]])
  1240.                             ->normalizeKeys(false)
  1241.                             ->useAttributeAsKey('name')
  1242.                             ->arrayPrototype()
  1243.                                 ->addDefaultsIfNotSet()
  1244.                                 ->children()
  1245.                                     ->enumNode('default_middleware')
  1246.                                         ->values([truefalse'allow_no_handlers'])
  1247.                                         ->defaultTrue()
  1248.                                     ->end()
  1249.                                     ->arrayNode('middleware')
  1250.                                         ->performNoDeepMerging()
  1251.                                         ->beforeNormalization()
  1252.                                             ->ifTrue(function ($v) { return \is_string($v) || (\is_array($v) && !\is_int(key($v))); })
  1253.                                             ->then(function ($v) { return [$v]; })
  1254.                                         ->end()
  1255.                                         ->defaultValue([])
  1256.                                         ->arrayPrototype()
  1257.                                             ->beforeNormalization()
  1258.                                                 ->always()
  1259.                                                 ->then(function ($middleware): array {
  1260.                                                     if (!\is_array($middleware)) {
  1261.                                                         return ['id' => $middleware];
  1262.                                                     }
  1263.                                                     if (isset($middleware['id'])) {
  1264.                                                         return $middleware;
  1265.                                                     }
  1266.                                                     if (< \count($middleware)) {
  1267.                                                         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.');
  1268.                                                     }
  1269.                                                     return [
  1270.                                                         'id' => key($middleware),
  1271.                                                         'arguments' => current($middleware),
  1272.                                                     ];
  1273.                                                 })
  1274.                                             ->end()
  1275.                                             ->fixXmlConfig('argument')
  1276.                                             ->children()
  1277.                                                 ->scalarNode('id')->isRequired()->cannotBeEmpty()->end()
  1278.                                                 ->arrayNode('arguments')
  1279.                                                     ->normalizeKeys(false)
  1280.                                                     ->defaultValue([])
  1281.                                                     ->prototype('variable')
  1282.                                                 ->end()
  1283.                                             ->end()
  1284.                                         ->end()
  1285.                                     ->end()
  1286.                                 ->end()
  1287.                             ->end()
  1288.                         ->end()
  1289.                     ->end()
  1290.                 ->end()
  1291.             ->end()
  1292.         ;
  1293.     }
  1294.     private function addRobotsIndexSection(ArrayNodeDefinition $rootNode)
  1295.     {
  1296.         $rootNode
  1297.             ->children()
  1298.                 ->booleanNode('disallow_search_engine_index')
  1299.                     ->info('Enabled by default when debug is enabled.')
  1300.                     ->defaultValue($this->debug)
  1301.                     ->treatNullLike($this->debug)
  1302.                 ->end()
  1303.             ->end()
  1304.         ;
  1305.     }
  1306.     private function addHttpClientSection(ArrayNodeDefinition $rootNode)
  1307.     {
  1308.         $rootNode
  1309.             ->children()
  1310.                 ->arrayNode('http_client')
  1311.                     ->info('HTTP Client configuration')
  1312.                     ->{!class_exists(FullStack::class) && class_exists(HttpClient::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1313.                     ->fixXmlConfig('scoped_client')
  1314.                     ->children()
  1315.                         ->integerNode('max_host_connections')
  1316.                             ->info('The maximum number of connections to a single host.')
  1317.                         ->end()
  1318.                         ->arrayNode('default_options')
  1319.                             ->fixXmlConfig('header')
  1320.                             ->children()
  1321.                                 ->arrayNode('headers')
  1322.                                     ->info('Associative array: header => value(s).')
  1323.                                     ->useAttributeAsKey('name')
  1324.                                     ->normalizeKeys(false)
  1325.                                     ->variablePrototype()->end()
  1326.                                 ->end()
  1327.                                 ->integerNode('max_redirects')
  1328.                                     ->info('The maximum number of redirects to follow.')
  1329.                                 ->end()
  1330.                                 ->scalarNode('http_version')
  1331.                                     ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1332.                                 ->end()
  1333.                                 ->arrayNode('resolve')
  1334.                                     ->info('Associative array: domain => IP.')
  1335.                                     ->useAttributeAsKey('host')
  1336.                                     ->beforeNormalization()
  1337.                                         ->always(function ($config) {
  1338.                                             if (!\is_array($config)) {
  1339.                                                 return [];
  1340.                                             }
  1341.                                             if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1342.                                                 return $config;
  1343.                                             }
  1344.                                             return [$config['host'] => $config['value']];
  1345.                                         })
  1346.                                     ->end()
  1347.                                     ->normalizeKeys(false)
  1348.                                     ->scalarPrototype()->end()
  1349.                                 ->end()
  1350.                                 ->scalarNode('proxy')
  1351.                                     ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1352.                                 ->end()
  1353.                                 ->scalarNode('no_proxy')
  1354.                                     ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1355.                                 ->end()
  1356.                                 ->floatNode('timeout')
  1357.                                     ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1358.                                 ->end()
  1359.                                 ->floatNode('max_duration')
  1360.                                     ->info('The maximum execution time for the request+response as a whole.')
  1361.                                 ->end()
  1362.                                 ->scalarNode('bindto')
  1363.                                     ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1364.                                 ->end()
  1365.                                 ->booleanNode('verify_peer')
  1366.                                     ->info('Indicates if the peer should be verified in an SSL/TLS context.')
  1367.                                 ->end()
  1368.                                 ->booleanNode('verify_host')
  1369.                                     ->info('Indicates if the host should exist as a certificate common name.')
  1370.                                 ->end()
  1371.                                 ->scalarNode('cafile')
  1372.                                     ->info('A certificate authority file.')
  1373.                                 ->end()
  1374.                                 ->scalarNode('capath')
  1375.                                     ->info('A directory that contains multiple certificate authority files.')
  1376.                                 ->end()
  1377.                                 ->scalarNode('local_cert')
  1378.                                     ->info('A PEM formatted certificate file.')
  1379.                                 ->end()
  1380.                                 ->scalarNode('local_pk')
  1381.                                     ->info('A private key file.')
  1382.                                 ->end()
  1383.                                 ->scalarNode('passphrase')
  1384.                                     ->info('The passphrase used to encrypt the "local_pk" file.')
  1385.                                 ->end()
  1386.                                 ->scalarNode('ciphers')
  1387.                                     ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1388.                                 ->end()
  1389.                                 ->arrayNode('peer_fingerprint')
  1390.                                     ->info('Associative array: hashing algorithm => hash(es).')
  1391.                                     ->normalizeKeys(false)
  1392.                                     ->children()
  1393.                                         ->variableNode('sha1')->end()
  1394.                                         ->variableNode('pin-sha256')->end()
  1395.                                         ->variableNode('md5')->end()
  1396.                                     ->end()
  1397.                                 ->end()
  1398.                             ->end()
  1399.                         ->end()
  1400.                         ->arrayNode('scoped_clients')
  1401.                             ->useAttributeAsKey('name')
  1402.                             ->normalizeKeys(false)
  1403.                             ->arrayPrototype()
  1404.                                 ->fixXmlConfig('header')
  1405.                                 ->beforeNormalization()
  1406.                                     ->always()
  1407.                                     ->then(function ($config) {
  1408.                                         if (!class_exists(HttpClient::class)) {
  1409.                                             throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
  1410.                                         }
  1411.                                         return \is_array($config) ? $config : ['base_uri' => $config];
  1412.                                     })
  1413.                                 ->end()
  1414.                                 ->validate()
  1415.                                     ->ifTrue(function ($v) { return !isset($v['scope']) && !isset($v['base_uri']); })
  1416.                                     ->thenInvalid('Either "scope" or "base_uri" should be defined.')
  1417.                                 ->end()
  1418.                                 ->validate()
  1419.                                     ->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); })
  1420.                                     ->thenInvalid('"query" applies to "base_uri" but no base URI is defined.')
  1421.                                 ->end()
  1422.                                 ->children()
  1423.                                     ->scalarNode('scope')
  1424.                                         ->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.')
  1425.                                         ->cannotBeEmpty()
  1426.                                     ->end()
  1427.                                     ->scalarNode('base_uri')
  1428.                                         ->info('The URI to resolve relative URLs, following rules in RFC 3985, section 2.')
  1429.                                         ->cannotBeEmpty()
  1430.                                     ->end()
  1431.                                     ->scalarNode('auth_basic')
  1432.                                         ->info('An HTTP Basic authentication "username:password".')
  1433.                                     ->end()
  1434.                                     ->scalarNode('auth_bearer')
  1435.                                         ->info('A token enabling HTTP Bearer authorization.')
  1436.                                     ->end()
  1437.                                     ->scalarNode('auth_ntlm')
  1438.                                         ->info('A "username:password" pair to use Microsoft NTLM authentication (requires the cURL extension).')
  1439.                                     ->end()
  1440.                                     ->arrayNode('query')
  1441.                                         ->info('Associative array of query string values merged with the base URI.')
  1442.                                         ->useAttributeAsKey('key')
  1443.                                         ->beforeNormalization()
  1444.                                             ->always(function ($config) {
  1445.                                                 if (!\is_array($config)) {
  1446.                                                     return [];
  1447.                                                 }
  1448.                                                 if (!isset($config['key'], $config['value']) || \count($config) > 2) {
  1449.                                                     return $config;
  1450.                                                 }
  1451.                                                 return [$config['key'] => $config['value']];
  1452.                                             })
  1453.                                         ->end()
  1454.                                         ->normalizeKeys(false)
  1455.                                         ->scalarPrototype()->end()
  1456.                                     ->end()
  1457.                                     ->arrayNode('headers')
  1458.                                         ->info('Associative array: header => value(s).')
  1459.                                         ->useAttributeAsKey('name')
  1460.                                         ->normalizeKeys(false)
  1461.                                         ->variablePrototype()->end()
  1462.                                     ->end()
  1463.                                     ->integerNode('max_redirects')
  1464.                                         ->info('The maximum number of redirects to follow.')
  1465.                                     ->end()
  1466.                                     ->scalarNode('http_version')
  1467.                                         ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1468.                                     ->end()
  1469.                                     ->arrayNode('resolve')
  1470.                                         ->info('Associative array: domain => IP.')
  1471.                                         ->useAttributeAsKey('host')
  1472.                                         ->beforeNormalization()
  1473.                                             ->always(function ($config) {
  1474.                                                 if (!\is_array($config)) {
  1475.                                                     return [];
  1476.                                                 }
  1477.                                                 if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1478.                                                     return $config;
  1479.                                                 }
  1480.                                                 return [$config['host'] => $config['value']];
  1481.                                             })
  1482.                                         ->end()
  1483.                                         ->normalizeKeys(false)
  1484.                                         ->scalarPrototype()->end()
  1485.                                     ->end()
  1486.                                     ->scalarNode('proxy')
  1487.                                         ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1488.                                     ->end()
  1489.                                     ->scalarNode('no_proxy')
  1490.                                         ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1491.                                     ->end()
  1492.                                     ->floatNode('timeout')
  1493.                                         ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1494.                                     ->end()
  1495.                                     ->floatNode('max_duration')
  1496.                                         ->info('The maximum execution time for the request+response as a whole.')
  1497.                                     ->end()
  1498.                                     ->scalarNode('bindto')
  1499.                                         ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1500.                                     ->end()
  1501.                                     ->booleanNode('verify_peer')
  1502.                                         ->info('Indicates if the peer should be verified in an SSL/TLS context.')
  1503.                                     ->end()
  1504.                                     ->booleanNode('verify_host')
  1505.                                         ->info('Indicates if the host should exist as a certificate common name.')
  1506.                                     ->end()
  1507.                                     ->scalarNode('cafile')
  1508.                                         ->info('A certificate authority file.')
  1509.                                     ->end()
  1510.                                     ->scalarNode('capath')
  1511.                                         ->info('A directory that contains multiple certificate authority files.')
  1512.                                     ->end()
  1513.                                     ->scalarNode('local_cert')
  1514.                                         ->info('A PEM formatted certificate file.')
  1515.                                     ->end()
  1516.                                     ->scalarNode('local_pk')
  1517.                                         ->info('A private key file.')
  1518.                                     ->end()
  1519.                                     ->scalarNode('passphrase')
  1520.                                         ->info('The passphrase used to encrypt the "local_pk" file.')
  1521.                                     ->end()
  1522.                                     ->scalarNode('ciphers')
  1523.                                         ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1524.                                     ->end()
  1525.                                     ->arrayNode('peer_fingerprint')
  1526.                                         ->info('Associative array: hashing algorithm => hash(es).')
  1527.                                         ->normalizeKeys(false)
  1528.                                         ->children()
  1529.                                             ->variableNode('sha1')->end()
  1530.                                             ->variableNode('pin-sha256')->end()
  1531.                                             ->variableNode('md5')->end()
  1532.                                         ->end()
  1533.                                     ->end()
  1534.                                 ->end()
  1535.                             ->end()
  1536.                         ->end()
  1537.                     ->end()
  1538.                 ->end()
  1539.             ->end()
  1540.         ;
  1541.     }
  1542.     private function addMailerSection(ArrayNodeDefinition $rootNode)
  1543.     {
  1544.         $rootNode
  1545.             ->children()
  1546.                 ->arrayNode('mailer')
  1547.                     ->info('Mailer configuration')
  1548.                     ->{!class_exists(FullStack::class) && class_exists(Mailer::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1549.                     ->validate()
  1550.                         ->ifTrue(function ($v) { return isset($v['dsn']) && \count($v['transports']); })
  1551.                         ->thenInvalid('"dsn" and "transports" cannot be used together.')
  1552.                     ->end()
  1553.                     ->fixXmlConfig('transport')
  1554.                     ->children()
  1555.                         ->scalarNode('dsn')->defaultNull()->end()
  1556.                         ->arrayNode('transports')
  1557.                             ->useAttributeAsKey('name')
  1558.                             ->prototype('scalar')->end()
  1559.                         ->end()
  1560.                         ->arrayNode('envelope')
  1561.                             ->info('Mailer Envelope configuration')
  1562.                             ->children()
  1563.                                 ->scalarNode('sender')->end()
  1564.                                 ->arrayNode('recipients')
  1565.                                     ->performNoDeepMerging()
  1566.                                     ->beforeNormalization()
  1567.                                     ->ifArray()
  1568.                                         ->then(function ($v) {
  1569.                                             return array_filter(array_values($v));
  1570.                                         })
  1571.                                     ->end()
  1572.                                     ->prototype('scalar')->end()
  1573.                                 ->end()
  1574.                             ->end()
  1575.                         ->end()
  1576.                     ->end()
  1577.                 ->end()
  1578.             ->end()
  1579.         ;
  1580.     }
  1581. }