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

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