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

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['adapters']) || \is_array($v['adapter'] ?? null)) && isset($v['provider']); })
  965.                                     ->thenInvalid('Pool cannot have a "provider" while "adapter" is set to a map')
  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()
  972.                                             ->always()->then(function ($values) {
  973.                                                 if ([0] === array_keys($values) && \is_array($values[0])) {
  974.                                                     return $values[0];
  975.                                                 }
  976.                                                 $adapters = [];
  977.                                                 foreach ($values as $k => $v) {
  978.                                                     if (\is_int($k) && \is_string($v)) {
  979.                                                         $adapters[] = $v;
  980.                                                     } elseif (!\is_array($v)) {
  981.                                                         $adapters[$k] = $v;
  982.                                                     } elseif (isset($v['provider'])) {
  983.                                                         $adapters[$v['provider']] = $v['name'] ?? $v;
  984.                                                     } else {
  985.                                                         $adapters[] = $v['name'] ?? $v;
  986.                                                     }
  987.                                                 }
  988.                                                 return $adapters;
  989.                                             })
  990.                                         ->end()
  991.                                         ->prototype('scalar')->end()
  992.                                     ->end()
  993.                                     ->scalarNode('tags')->defaultNull()->end()
  994.                                     ->booleanNode('public')->defaultFalse()->end()
  995.                                     ->integerNode('default_lifetime')->end()
  996.                                     ->scalarNode('provider')
  997.                                         ->info('Overwrite the setting from the default provider for this adapter.')
  998.                                     ->end()
  999.                                     ->scalarNode('clearer')->end()
  1000.                                 ->end()
  1001.                             ->end()
  1002.                             ->validate()
  1003.                                 ->ifTrue(function ($v) { return isset($v['cache.app']) || isset($v['cache.system']); })
  1004.                                 ->thenInvalid('"cache.app" and "cache.system" are reserved names')
  1005.                             ->end()
  1006.                         ->end()
  1007.                     ->end()
  1008.                 ->end()
  1009.             ->end()
  1010.         ;
  1011.     }
  1012.     private function addPhpErrorsSection(ArrayNodeDefinition $rootNode)
  1013.     {
  1014.         $rootNode
  1015.             ->children()
  1016.                 ->arrayNode('php_errors')
  1017.                     ->info('PHP errors handling configuration')
  1018.                     ->addDefaultsIfNotSet()
  1019.                     ->children()
  1020.                         ->scalarNode('log')
  1021.                             ->info('Use the application logger instead of the PHP logger for logging PHP errors.')
  1022.                             ->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants.')
  1023.                             ->defaultValue($this->debug)
  1024.                             ->treatNullLike($this->debug)
  1025.                             ->validate()
  1026.                                 ->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); })
  1027.                                 ->thenInvalid('The "php_errors.log" parameter should be either an integer or a boolean.')
  1028.                             ->end()
  1029.                         ->end()
  1030.                         ->booleanNode('throw')
  1031.                             ->info('Throw PHP errors as \ErrorException instances.')
  1032.                             ->defaultValue($this->debug)
  1033.                             ->treatNullLike($this->debug)
  1034.                         ->end()
  1035.                     ->end()
  1036.                 ->end()
  1037.             ->end()
  1038.         ;
  1039.     }
  1040.     private function addLockSection(ArrayNodeDefinition $rootNode)
  1041.     {
  1042.         $rootNode
  1043.             ->children()
  1044.                 ->arrayNode('lock')
  1045.                     ->info('Lock configuration')
  1046.                     ->{!class_exists(FullStack::class) && class_exists(Lock::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1047.                     ->beforeNormalization()
  1048.                         ->ifString()->then(function ($v) { return ['enabled' => true'resources' => $v]; })
  1049.                     ->end()
  1050.                     ->beforeNormalization()
  1051.                         ->ifTrue(function ($v) { return \is_array($v) && !isset($v['enabled']); })
  1052.                         ->then(function ($v) { return $v + ['enabled' => true]; })
  1053.                     ->end()
  1054.                     ->beforeNormalization()
  1055.                         ->ifTrue(function ($v) { return \is_array($v) && !isset($v['resources']) && !isset($v['resource']); })
  1056.                         ->then(function ($v) {
  1057.                             $e $v['enabled'];
  1058.                             unset($v['enabled']);
  1059.                             return ['enabled' => $e'resources' => $v];
  1060.                         })
  1061.                     ->end()
  1062.                     ->addDefaultsIfNotSet()
  1063.                     ->fixXmlConfig('resource')
  1064.                     ->children()
  1065.                         ->arrayNode('resources')
  1066.                             ->normalizeKeys(false)
  1067.                             ->useAttributeAsKey('name')
  1068.                             ->requiresAtLeastOneElement()
  1069.                             ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' 'flock']])
  1070.                             ->beforeNormalization()
  1071.                                 ->ifString()->then(function ($v) { return ['default' => $v]; })
  1072.                             ->end()
  1073.                             ->beforeNormalization()
  1074.                                 ->ifTrue(function ($v) { return \is_array($v) && array_keys($v) === range(0\count($v) - 1); })
  1075.                                 ->then(function ($v) {
  1076.                                     $resources = [];
  1077.                                     foreach ($v as $resource) {
  1078.                                         $resources array_merge_recursive(
  1079.                                             $resources,
  1080.                                             \is_array($resource) && isset($resource['name'])
  1081.                                                 ? [$resource['name'] => $resource['value']]
  1082.                                                 : ['default' => $resource]
  1083.                                         );
  1084.                                     }
  1085.                                     return $resources;
  1086.                                 })
  1087.                             ->end()
  1088.                             ->prototype('array')
  1089.                                 ->performNoDeepMerging()
  1090.                                 ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
  1091.                                 ->prototype('scalar')->end()
  1092.                             ->end()
  1093.                         ->end()
  1094.                     ->end()
  1095.                 ->end()
  1096.             ->end()
  1097.         ;
  1098.     }
  1099.     private function addWebLinkSection(ArrayNodeDefinition $rootNode)
  1100.     {
  1101.         $rootNode
  1102.             ->children()
  1103.                 ->arrayNode('web_link')
  1104.                     ->info('web links configuration')
  1105.                     ->{!class_exists(FullStack::class) && class_exists(HttpHeaderSerializer::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1106.                 ->end()
  1107.             ->end()
  1108.         ;
  1109.     }
  1110.     private function addMessengerSection(ArrayNodeDefinition $rootNode)
  1111.     {
  1112.         $rootNode
  1113.             ->children()
  1114.                 ->arrayNode('messenger')
  1115.                     ->info('Messenger configuration')
  1116.                     ->{!class_exists(FullStack::class) && interface_exists(MessageBusInterface::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1117.                     ->fixXmlConfig('transport')
  1118.                     ->fixXmlConfig('bus''buses')
  1119.                     ->validate()
  1120.                         ->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > && null === $v['default_bus']; })
  1121.                         ->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
  1122.                     ->end()
  1123.                     ->validate()
  1124.                         ->ifTrue(static function ($v): bool { return isset($v['buses']) && null !== $v['default_bus'] && !isset($v['buses'][$v['default_bus']]); })
  1125.                         ->then(static function (array $v): void { throw new InvalidConfigurationException(sprintf('The specified default bus "%s" is not configured. Available buses are "%s".'$v['default_bus'], implode('", "'array_keys($v['buses'])))); })
  1126.                     ->end()
  1127.                     ->children()
  1128.                         ->arrayNode('routing')
  1129.                             ->normalizeKeys(false)
  1130.                             ->useAttributeAsKey('message_class')
  1131.                             ->beforeNormalization()
  1132.                                 ->always()
  1133.                                 ->then(function ($config) {
  1134.                                     if (!\is_array($config)) {
  1135.                                         return [];
  1136.                                     }
  1137.                                     // If XML config with only one routing attribute
  1138.                                     if (=== \count($config) && isset($config['message-class']) && isset($config['sender'])) {
  1139.                                         $config = [=> $config];
  1140.                                     }
  1141.                                     $newConfig = [];
  1142.                                     foreach ($config as $k => $v) {
  1143.                                         if (!\is_int($k)) {
  1144.                                             $newConfig[$k] = [
  1145.                                                 'senders' => $v['senders'] ?? (\is_array($v) ? array_values($v) : [$v]),
  1146.                                             ];
  1147.                                         } else {
  1148.                                             $newConfig[$v['message-class']]['senders'] = array_map(
  1149.                                                 function ($a) {
  1150.                                                     return \is_string($a) ? $a $a['service'];
  1151.                                                 },
  1152.                                                 array_values($v['sender'])
  1153.                                             );
  1154.                                         }
  1155.                                     }
  1156.                                     return $newConfig;
  1157.                                 })
  1158.                             ->end()
  1159.                             ->prototype('array')
  1160.                                 ->performNoDeepMerging()
  1161.                                 ->children()
  1162.                                     ->arrayNode('senders')
  1163.                                         ->requiresAtLeastOneElement()
  1164.                                         ->prototype('scalar')->end()
  1165.                                     ->end()
  1166.                                 ->end()
  1167.                             ->end()
  1168.                         ->end()
  1169.                         ->arrayNode('serializer')
  1170.                             ->addDefaultsIfNotSet()
  1171.                             ->children()
  1172.                                 ->scalarNode('default_serializer')
  1173.                                     ->defaultValue('messenger.transport.native_php_serializer')
  1174.                                     ->info('Service id to use as the default serializer for the transports.')
  1175.                                 ->end()
  1176.                                 ->arrayNode('symfony_serializer')
  1177.                                     ->addDefaultsIfNotSet()
  1178.                                     ->children()
  1179.                                         ->scalarNode('format')->defaultValue('json')->info('Serialization format for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')->end()
  1180.                                         ->arrayNode('context')
  1181.                                             ->normalizeKeys(false)
  1182.                                             ->useAttributeAsKey('name')
  1183.                                             ->defaultValue([])
  1184.                                             ->info('Context array for the messenger.transport.symfony_serializer service (which is not the serializer used by default).')
  1185.                                             ->prototype('variable')->end()
  1186.                                         ->end()
  1187.                                     ->end()
  1188.                                 ->end()
  1189.                             ->end()
  1190.                         ->end()
  1191.                         ->arrayNode('transports')
  1192.                             ->normalizeKeys(false)
  1193.                             ->useAttributeAsKey('name')
  1194.                             ->arrayPrototype()
  1195.                                 ->beforeNormalization()
  1196.                                     ->ifString()
  1197.                                     ->then(function (string $dsn) {
  1198.                                         return ['dsn' => $dsn];
  1199.                                     })
  1200.                                 ->end()
  1201.                                 ->fixXmlConfig('option')
  1202.                                 ->children()
  1203.                                     ->scalarNode('dsn')->end()
  1204.                                     ->scalarNode('serializer')->defaultNull()->info('Service id of a custom serializer to use.')->end()
  1205.                                     ->arrayNode('options')
  1206.                                         ->normalizeKeys(false)
  1207.                                         ->defaultValue([])
  1208.                                         ->prototype('variable')
  1209.                                         ->end()
  1210.                                     ->end()
  1211.                                     ->arrayNode('retry_strategy')
  1212.                                         ->addDefaultsIfNotSet()
  1213.                                         ->beforeNormalization()
  1214.                                             ->always(function ($v) {
  1215.                                                 if (isset($v['service']) && (isset($v['max_retries']) || isset($v['delay']) || isset($v['multiplier']) || isset($v['max_delay']))) {
  1216.                                                     throw new \InvalidArgumentException('The "service" cannot be used along with the other "retry_strategy" options.');
  1217.                                                 }
  1218.                                                 return $v;
  1219.                                             })
  1220.                                         ->end()
  1221.                                         ->children()
  1222.                                             ->scalarNode('service')->defaultNull()->info('Service id to override the retry strategy entirely')->end()
  1223.                                             ->integerNode('max_retries')->defaultValue(3)->min(0)->end()
  1224.                                             ->integerNode('delay')->defaultValue(1000)->min(0)->info('Time in ms to delay (or the initial value when multiplier is used)')->end()
  1225.                                             ->floatNode('multiplier')->defaultValue(2)->min(1)->info('If greater than 1, delay will grow exponentially for each retry: this delay = (delay * (multiple ^ retries))')->end()
  1226.                                             ->integerNode('max_delay')->defaultValue(0)->min(0)->info('Max time in ms that a retry should ever be delayed (0 = infinite)')->end()
  1227.                                         ->end()
  1228.                                     ->end()
  1229.                                 ->end()
  1230.                             ->end()
  1231.                         ->end()
  1232.                         ->scalarNode('failure_transport')
  1233.                             ->defaultNull()
  1234.                             ->info('Transport name to send failed messages to (after all retries have failed).')
  1235.                         ->end()
  1236.                         ->scalarNode('default_bus')->defaultNull()->end()
  1237.                         ->arrayNode('buses')
  1238.                             ->defaultValue(['messenger.bus.default' => ['default_middleware' => true'middleware' => []]])
  1239.                             ->normalizeKeys(false)
  1240.                             ->useAttributeAsKey('name')
  1241.                             ->arrayPrototype()
  1242.                                 ->addDefaultsIfNotSet()
  1243.                                 ->children()
  1244.                                     ->enumNode('default_middleware')
  1245.                                         ->values([truefalse'allow_no_handlers'])
  1246.                                         ->defaultTrue()
  1247.                                     ->end()
  1248.                                     ->arrayNode('middleware')
  1249.                                         ->performNoDeepMerging()
  1250.                                         ->beforeNormalization()
  1251.                                             ->ifTrue(function ($v) { return \is_string($v) || (\is_array($v) && !\is_int(key($v))); })
  1252.                                             ->then(function ($v) { return [$v]; })
  1253.                                         ->end()
  1254.                                         ->defaultValue([])
  1255.                                         ->arrayPrototype()
  1256.                                             ->beforeNormalization()
  1257.                                                 ->always()
  1258.                                                 ->then(function ($middleware): array {
  1259.                                                     if (!\is_array($middleware)) {
  1260.                                                         return ['id' => $middleware];
  1261.                                                     }
  1262.                                                     if (isset($middleware['id'])) {
  1263.                                                         return $middleware;
  1264.                                                     }
  1265.                                                     if (\count($middleware)) {
  1266.                                                         throw new \InvalidArgumentException('Invalid middleware at path "framework.messenger": a map with a single factory id as key and its arguments as value was expected, '.json_encode($middleware).' given.');
  1267.                                                     }
  1268.                                                     return [
  1269.                                                         'id' => key($middleware),
  1270.                                                         'arguments' => current($middleware),
  1271.                                                     ];
  1272.                                                 })
  1273.                                             ->end()
  1274.                                             ->fixXmlConfig('argument')
  1275.                                             ->children()
  1276.                                                 ->scalarNode('id')->isRequired()->cannotBeEmpty()->end()
  1277.                                                 ->arrayNode('arguments')
  1278.                                                     ->normalizeKeys(false)
  1279.                                                     ->defaultValue([])
  1280.                                                     ->prototype('variable')
  1281.                                                 ->end()
  1282.                                             ->end()
  1283.                                         ->end()
  1284.                                     ->end()
  1285.                                 ->end()
  1286.                             ->end()
  1287.                         ->end()
  1288.                     ->end()
  1289.                 ->end()
  1290.             ->end()
  1291.         ;
  1292.     }
  1293.     private function addRobotsIndexSection(ArrayNodeDefinition $rootNode)
  1294.     {
  1295.         $rootNode
  1296.             ->children()
  1297.                 ->booleanNode('disallow_search_engine_index')
  1298.                     ->info('Enabled by default when debug is enabled.')
  1299.                     ->defaultValue($this->debug)
  1300.                     ->treatNullLike($this->debug)
  1301.                 ->end()
  1302.             ->end()
  1303.         ;
  1304.     }
  1305.     private function addHttpClientSection(ArrayNodeDefinition $rootNode)
  1306.     {
  1307.         $rootNode
  1308.             ->children()
  1309.                 ->arrayNode('http_client')
  1310.                     ->info('HTTP Client configuration')
  1311.                     ->{!class_exists(FullStack::class) && class_exists(HttpClient::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1312.                     ->fixXmlConfig('scoped_client')
  1313.                     ->children()
  1314.                         ->integerNode('max_host_connections')
  1315.                             ->info('The maximum number of connections to a single host.')
  1316.                         ->end()
  1317.                         ->arrayNode('default_options')
  1318.                             ->fixXmlConfig('header')
  1319.                             ->children()
  1320.                                 ->arrayNode('headers')
  1321.                                     ->info('Associative array: header => value(s).')
  1322.                                     ->useAttributeAsKey('name')
  1323.                                     ->normalizeKeys(false)
  1324.                                     ->variablePrototype()->end()
  1325.                                 ->end()
  1326.                                 ->integerNode('max_redirects')
  1327.                                     ->info('The maximum number of redirects to follow.')
  1328.                                 ->end()
  1329.                                 ->scalarNode('http_version')
  1330.                                     ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1331.                                 ->end()
  1332.                                 ->arrayNode('resolve')
  1333.                                     ->info('Associative array: domain => IP.')
  1334.                                     ->useAttributeAsKey('host')
  1335.                                     ->beforeNormalization()
  1336.                                         ->always(function ($config) {
  1337.                                             if (!\is_array($config)) {
  1338.                                                 return [];
  1339.                                             }
  1340.                                             if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1341.                                                 return $config;
  1342.                                             }
  1343.                                             return [$config['host'] => $config['value']];
  1344.                                         })
  1345.                                     ->end()
  1346.                                     ->normalizeKeys(false)
  1347.                                     ->scalarPrototype()->end()
  1348.                                 ->end()
  1349.                                 ->scalarNode('proxy')
  1350.                                     ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1351.                                 ->end()
  1352.                                 ->scalarNode('no_proxy')
  1353.                                     ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1354.                                 ->end()
  1355.                                 ->floatNode('timeout')
  1356.                                     ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1357.                                 ->end()
  1358.                                 ->floatNode('max_duration')
  1359.                                     ->info('The maximum execution time for the request+response as a whole.')
  1360.                                 ->end()
  1361.                                 ->scalarNode('bindto')
  1362.                                     ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1363.                                 ->end()
  1364.                                 ->booleanNode('verify_peer')
  1365.                                     ->info('Indicates if the peer should be verified in an SSL/TLS context.')
  1366.                                 ->end()
  1367.                                 ->booleanNode('verify_host')
  1368.                                     ->info('Indicates if the host should exist as a certificate common name.')
  1369.                                 ->end()
  1370.                                 ->scalarNode('cafile')
  1371.                                     ->info('A certificate authority file.')
  1372.                                 ->end()
  1373.                                 ->scalarNode('capath')
  1374.                                     ->info('A directory that contains multiple certificate authority files.')
  1375.                                 ->end()
  1376.                                 ->scalarNode('local_cert')
  1377.                                     ->info('A PEM formatted certificate file.')
  1378.                                 ->end()
  1379.                                 ->scalarNode('local_pk')
  1380.                                     ->info('A private key file.')
  1381.                                 ->end()
  1382.                                 ->scalarNode('passphrase')
  1383.                                     ->info('The passphrase used to encrypt the "local_pk" file.')
  1384.                                 ->end()
  1385.                                 ->scalarNode('ciphers')
  1386.                                     ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1387.                                 ->end()
  1388.                                 ->arrayNode('peer_fingerprint')
  1389.                                     ->info('Associative array: hashing algorithm => hash(es).')
  1390.                                     ->normalizeKeys(false)
  1391.                                     ->children()
  1392.                                         ->variableNode('sha1')->end()
  1393.                                         ->variableNode('pin-sha256')->end()
  1394.                                         ->variableNode('md5')->end()
  1395.                                     ->end()
  1396.                                 ->end()
  1397.                             ->end()
  1398.                         ->end()
  1399.                         ->arrayNode('scoped_clients')
  1400.                             ->useAttributeAsKey('name')
  1401.                             ->normalizeKeys(false)
  1402.                             ->arrayPrototype()
  1403.                                 ->fixXmlConfig('header')
  1404.                                 ->beforeNormalization()
  1405.                                     ->always()
  1406.                                     ->then(function ($config) {
  1407.                                         if (!class_exists(HttpClient::class)) {
  1408.                                             throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
  1409.                                         }
  1410.                                         return \is_array($config) ? $config : ['base_uri' => $config];
  1411.                                     })
  1412.                                 ->end()
  1413.                                 ->validate()
  1414.                                     ->ifTrue(function ($v) { return !isset($v['scope']) && !isset($v['base_uri']); })
  1415.                                     ->thenInvalid('Either "scope" or "base_uri" should be defined.')
  1416.                                 ->end()
  1417.                                 ->validate()
  1418.                                     ->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); })
  1419.                                     ->thenInvalid('"query" applies to "base_uri" but no base URI is defined.')
  1420.                                 ->end()
  1421.                                 ->children()
  1422.                                     ->scalarNode('scope')
  1423.                                         ->info('The regular expression that the request URL must match before adding the other options. When none is provided, the base URI is used instead.')
  1424.                                         ->cannotBeEmpty()
  1425.                                     ->end()
  1426.                                     ->scalarNode('base_uri')
  1427.                                         ->info('The URI to resolve relative URLs, following rules in RFC 3985, section 2.')
  1428.                                         ->cannotBeEmpty()
  1429.                                     ->end()
  1430.                                     ->scalarNode('auth_basic')
  1431.                                         ->info('An HTTP Basic authentication "username:password".')
  1432.                                     ->end()
  1433.                                     ->scalarNode('auth_bearer')
  1434.                                         ->info('A token enabling HTTP Bearer authorization.')
  1435.                                     ->end()
  1436.                                     ->scalarNode('auth_ntlm')
  1437.                                         ->info('A "username:password" pair to use Microsoft NTLM authentication (requires the cURL extension).')
  1438.                                     ->end()
  1439.                                     ->arrayNode('query')
  1440.                                         ->info('Associative array of query string values merged with the base URI.')
  1441.                                         ->useAttributeAsKey('key')
  1442.                                         ->beforeNormalization()
  1443.                                             ->always(function ($config) {
  1444.                                                 if (!\is_array($config)) {
  1445.                                                     return [];
  1446.                                                 }
  1447.                                                 if (!isset($config['key'], $config['value']) || \count($config) > 2) {
  1448.                                                     return $config;
  1449.                                                 }
  1450.                                                 return [$config['key'] => $config['value']];
  1451.                                             })
  1452.                                         ->end()
  1453.                                         ->normalizeKeys(false)
  1454.                                         ->scalarPrototype()->end()
  1455.                                     ->end()
  1456.                                     ->arrayNode('headers')
  1457.                                         ->info('Associative array: header => value(s).')
  1458.                                         ->useAttributeAsKey('name')
  1459.                                         ->normalizeKeys(false)
  1460.                                         ->variablePrototype()->end()
  1461.                                     ->end()
  1462.                                     ->integerNode('max_redirects')
  1463.                                         ->info('The maximum number of redirects to follow.')
  1464.                                     ->end()
  1465.                                     ->scalarNode('http_version')
  1466.                                         ->info('The default HTTP version, typically 1.1 or 2.0, leave to null for the best version.')
  1467.                                     ->end()
  1468.                                     ->arrayNode('resolve')
  1469.                                         ->info('Associative array: domain => IP.')
  1470.                                         ->useAttributeAsKey('host')
  1471.                                         ->beforeNormalization()
  1472.                                             ->always(function ($config) {
  1473.                                                 if (!\is_array($config)) {
  1474.                                                     return [];
  1475.                                                 }
  1476.                                                 if (!isset($config['host'], $config['value']) || \count($config) > 2) {
  1477.                                                     return $config;
  1478.                                                 }
  1479.                                                 return [$config['host'] => $config['value']];
  1480.                                             })
  1481.                                         ->end()
  1482.                                         ->normalizeKeys(false)
  1483.                                         ->scalarPrototype()->end()
  1484.                                     ->end()
  1485.                                     ->scalarNode('proxy')
  1486.                                         ->info('The URL of the proxy to pass requests through or null for automatic detection.')
  1487.                                     ->end()
  1488.                                     ->scalarNode('no_proxy')
  1489.                                         ->info('A comma separated list of hosts that do not require a proxy to be reached.')
  1490.                                     ->end()
  1491.                                     ->floatNode('timeout')
  1492.                                         ->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
  1493.                                     ->end()
  1494.                                     ->floatNode('max_duration')
  1495.                                         ->info('The maximum execution time for the request+response as a whole.')
  1496.                                     ->end()
  1497.                                     ->scalarNode('bindto')
  1498.                                         ->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
  1499.                                     ->end()
  1500.                                     ->booleanNode('verify_peer')
  1501.                                         ->info('Indicates if the peer should be verified in an SSL/TLS context.')
  1502.                                     ->end()
  1503.                                     ->booleanNode('verify_host')
  1504.                                         ->info('Indicates if the host should exist as a certificate common name.')
  1505.                                     ->end()
  1506.                                     ->scalarNode('cafile')
  1507.                                         ->info('A certificate authority file.')
  1508.                                     ->end()
  1509.                                     ->scalarNode('capath')
  1510.                                         ->info('A directory that contains multiple certificate authority files.')
  1511.                                     ->end()
  1512.                                     ->scalarNode('local_cert')
  1513.                                         ->info('A PEM formatted certificate file.')
  1514.                                     ->end()
  1515.                                     ->scalarNode('local_pk')
  1516.                                         ->info('A private key file.')
  1517.                                     ->end()
  1518.                                     ->scalarNode('passphrase')
  1519.                                         ->info('The passphrase used to encrypt the "local_pk" file.')
  1520.                                     ->end()
  1521.                                     ->scalarNode('ciphers')
  1522.                                         ->info('A list of SSL/TLS ciphers separated by colons, commas or spaces (e.g. "RC3-SHA:TLS13-AES-128-GCM-SHA256"...)')
  1523.                                     ->end()
  1524.                                     ->arrayNode('peer_fingerprint')
  1525.                                         ->info('Associative array: hashing algorithm => hash(es).')
  1526.                                         ->normalizeKeys(false)
  1527.                                         ->children()
  1528.                                             ->variableNode('sha1')->end()
  1529.                                             ->variableNode('pin-sha256')->end()
  1530.                                             ->variableNode('md5')->end()
  1531.                                         ->end()
  1532.                                     ->end()
  1533.                                 ->end()
  1534.                             ->end()
  1535.                         ->end()
  1536.                     ->end()
  1537.                 ->end()
  1538.             ->end()
  1539.         ;
  1540.     }
  1541.     private function addMailerSection(ArrayNodeDefinition $rootNode)
  1542.     {
  1543.         $rootNode
  1544.             ->children()
  1545.                 ->arrayNode('mailer')
  1546.                     ->info('Mailer configuration')
  1547.                     ->{!class_exists(FullStack::class) && class_exists(Mailer::class) ? 'canBeDisabled' 'canBeEnabled'}()
  1548.                     ->validate()
  1549.                         ->ifTrue(function ($v) { return isset($v['dsn']) && \count($v['transports']); })
  1550.                         ->thenInvalid('"dsn" and "transports" cannot be used together.')
  1551.                     ->end()
  1552.                     ->fixXmlConfig('transport')
  1553.                     ->children()
  1554.                         ->scalarNode('dsn')->defaultNull()->end()
  1555.                         ->arrayNode('transports')
  1556.                             ->useAttributeAsKey('name')
  1557.                             ->prototype('scalar')->end()
  1558.                         ->end()
  1559.                         ->arrayNode('envelope')
  1560.                             ->info('Mailer Envelope configuration')
  1561.                             ->children()
  1562.                                 ->scalarNode('sender')->end()
  1563.                                 ->arrayNode('recipients')
  1564.                                     ->performNoDeepMerging()
  1565.                                     ->beforeNormalization()
  1566.                                     ->ifArray()
  1567.                                         ->then(function ($v) {
  1568.                                             return array_filter(array_values($v));
  1569.                                         })
  1570.                                     ->end()
  1571.                                     ->prototype('scalar')->end()
  1572.                                 ->end()
  1573.                             ->end()
  1574.                         ->end()
  1575.                     ->end()
  1576.                 ->end()
  1577.             ->end()
  1578.         ;
  1579.     }
  1580. }