Configure the root node.

@param ArrayNodeDefinition $rootNode
772183
protected function setupTree(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('mapping')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->append($this->addMappingNode(
                            'translation',
                            'Elcodi\Component\EntityTranslator\Entity\EntityTranslation',
                            '@ElcodiEntityTranslatorBundle/Resources/config/doctrine/EntityTranslation.orm.yml',
                            'default',
                            true
                        ))
                    ->end()
                ->end()
                ->scalarNode('cache_prefix')
                    ->defaultValue('translation')
                ->end()
                ->booleanNode('auto_translate')
                    ->defaultTrue()
                ->end()
                ->arrayNode('language')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('master_locale')
                            ->defaultValue('en')
                        ->end()
                        ->scalarNode('fallback')
                            ->defaultTrue()
                        ->end()
                    ->end()
                ->end()
                ->arrayNode('configuration')
                    ->useAttributeAsKey('name')
                    ->prototype('array')
                        ->children()
                            ->scalarNode('alias')
                                ->isRequired()
                                ->cannotBeEmpty()
                            ->end()
                            ->scalarNode('idGetter')
                                ->defaultValue('getId')
                            ->end()
                            ->arrayNode('fields')
                                ->prototype('array')
                                    ->children()
                                        ->scalarNode('setter')->end()
                                        ->scalarNode('getter')->end()
                                    ->end()
                                ->end()
                                ->beforeNormalization()
                                ->always(function ($fields) {
                                    foreach ($fields as $fieldName => $fieldConfiguration) {
                                        if (!is_array($fieldConfiguration)) {
                                            $fieldConfiguration = [];
                                        }

                                        if (!isset($fieldConfiguration['getter'])) {
                                            $fields[$fieldName]['getter'] = 'get' . ucfirst($fieldName);
                                        }

                                        if (!isset($fieldConfiguration['setter'])) {
                                            $fields[$fieldName]['setter'] = 'set' . ucfirst($fieldName);
                                        }
                                    }

                                    return $fields;
                                })
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
1295794
public function configure(ArrayNodeDefinition $builder) {
    $children = $builder->children();
    $children->scalarNode('phantom_server')->isRequired()->end();
    $children->scalarNode('template_cache')->defaultNull()->end();
  }
1168789
protected function setupTree(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()

                /**
                 * Bundle config definition.
                 */
                ->integerNode('resolver_priority')
                    ->defaultValue(-8)
                ->end()

                /**
                 * Provider request.
                 */
                ->enumNode('request')
                    ->values([
                        RequestParameterProvider::CURRENT_REQUEST,
                        RequestParameterProvider::MASTER_REQUEST,
                    ])
                    ->defaultValue(RequestParameterProvider::CURRENT_REQUEST)
                ->end()

                /**
                 * Form config definition.
                 */
                ->arrayNode('form')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('active')
                            ->defaultTrue()
                        ->end()
                        ->scalarNode('default_name')
                            ->defaultValue('form')
                        ->end()
                    ->end()
                ->end()

                /**
                 * Flush config definition.
                 */
                ->arrayNode('flush')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('active')
                            ->defaultTrue()
                        ->end()
                        ->scalarNode('default_manager')
                            ->defaultValue('default')
                        ->end()
                    ->end()
                ->end()

                /**
                 * Entity config definition.
                 */
                ->arrayNode('entity')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('active')
                            ->defaultTrue()
                        ->end()
                        ->scalarNode('default_name')
                            ->defaultValue('entity')
                        ->end()
                        ->scalarNode('default_persist')
                            ->defaultTrue()
                        ->end()
                        ->booleanNode('fallback_mapping')
                            ->defaultFalse()
                        ->end()
                         ->scalarNode('default_factory_method')
                            ->defaultValue('create')
                        ->end()
                        ->booleanNode('default_factory_static')
                            ->defaultValue(true)
                        ->end()
                    ->end()
                ->end()

                /**
                 * Bundle config definition.
                 */
                ->arrayNode('json_response')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('active')
                            ->defaultTrue()
                        ->end()
                        ->integerNode('default_status')
                            ->defaultValue(200)
                        ->end()
                        ->integerNode('default_error_status')
                            ->defaultValue(500)
                        ->end()
                        ->arrayNode('default_headers')
                            ->useAttributeAsKey('name')
                            ->prototype('scalar')
                            ->end()
                            ->defaultValue([])
                        ->end()
                    ->end()
                ->end()

                /**
                 * Log config definition.
                 */
                ->arrayNode('log')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('active')
                            ->defaultTrue()
                        ->end()
                        ->enumNode('default_level')
                            ->values([
                                AnnotationLog::LVL_EMERG,
                                AnnotationLog::LVL_ALERT,
                                AnnotationLog::LVL_CRIT,
                                AnnotationLog::LVL_ERR,
                                AnnotationLog::LVL_WARNING,
                                AnnotationLog::LVL_INFO,
                                AnnotationLog::LVL_DEBUG,
                                AnnotationLog::LVL_LOG,
                            ])
                            ->defaultValue(AnnotationLog::LVL_INFO)
                        ->end()
                        ->enumNode('default_execute')
                            ->values([
                                AnnotationLog::EXEC_PRE,
                                AnnotationLog::EXEC_POST,
                                AnnotationLog::EXEC_BOTH,
                            ])
                            ->defaultValue(AnnotationLog::EXEC_PRE)
                        ->end()
                    ->end()
                ->end()

                ->arrayNode('paginator')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('active')
                            ->defaultTrue()
                        ->end()
                        ->scalarNode('default_name')
                            ->defaultValue('paginator')
                        ->end()
                        ->integerNode('default_page')
                            ->defaultValue(1)
                        ->end()
                        ->integerNode('default_limit_per_page')
                            ->defaultValue(10)
                        ->end()
                    ->end()
                ->end()

                /**
                 * Get config definition.
                 */
                ->arrayNode('get')
                    ->addDefaultsIfNotSet()
                        ->children()
                            ->booleanNode('active')
                                ->defaultTrue()
                        ->end()
                    ->end()
                ->end()

                /**
                 * Post config definition.
                 */
                ->arrayNode('post')
                    ->addDefaultsIfNotSet()
                        ->children()
                            ->booleanNode('active')
                                ->defaultTrue()
                            ->end()
                        ->end()
                    ->end()
                ->end()

            ->end();
    }
1013545
private function addSchemaOrgSection(ArrayNodeDefinition $node)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $node
            ->children()
                ->arrayNode('schema_org')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('provider')
                            ->defaultValue([])
                            ->useAttributeAsKey('name')
                            ->prototype('scalar')->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
789041
public function addChild(self $resourceNode)
    {
        if (!$this->children->contains($resourceNode)) {
            $this->children->add($resourceNode);
        }
    }
709598
private function addResolveTargetDocumentsSection(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->fixXmlConfig('resolve_target_document')
            ->children()
                ->arrayNode('resolve_target_documents')
                    ->useAttributeAsKey('interface')
                    ->prototype('scalar')
                        ->cannotBeEmpty()
                    ->end()
                ->end()
            ->end();
    }
632824
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $default_events = implode(',', self::DEFAULT_EVENTS);

        $days      = (int) $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
        $filter    = $this->getBlockSetting($block_id, 'filter', self::DEFAULT_FILTER);
        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_STYLE);
        $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT);
        $events    = $this->getBlockSetting($block_id, 'events', $default_events);

        $event_array = explode(',', $events);

        $all_events = [];
        foreach (self::ALL_EVENTS as $event) {
            $all_events[$event] = GedcomTag::getLabel($event);
        }

        $info_styles = [
            /* I18N: An option in a list-box */
            'list'  => I18N::translate('list'),
            /* I18N: An option in a list-box */
            'table' => I18N::translate('table'),
        ];

        $sort_styles = [
            /* I18N: An option in a list-box */
            'alpha' => I18N::translate('sort by name'),
            /* I18N: An option in a list-box */
            'anniv' => I18N::translate('sort by date'),
        ];

        echo view('modules/upcoming_events/config', [
            'all_events'  => $all_events,
            'days'        => $days,
            'event_array' => $event_array,
            'filter'      => $filter,
            'infoStyle'   => $infoStyle,
            'info_styles' => $info_styles,
            'max_days'    => self::MAX_DAYS,
            'sortStyle'   => $sortStyle,
            'sort_styles' => $sort_styles,
        ]);
    }
460581
protected function addConnectionsSection($rootNode)
    {
        $rootNode
            ->fixXmlConfig('connection')
            ->children()
                ->arrayNode('connections')
                    ->useAttributeAsKey('id')
                    ->prototype('array')
                        //->performNoDeepMerging()
                        ->children()
                            ->scalarNode('class')->defaultValue('Mandango\Connection')->end()
                            ->scalarNode('server')->end()
                            ->scalarNode('database')->end()
                        ->end()
                        ->append($this->addConnectionOptionsNode())
                    ->end()
                ->end()
            ->end()
        ;
    }
878325
private function addAnnotationsSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('annotations')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('enabled')->defaultFalse()->cannotBeEmpty()->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
382578
private function addConnectionsSection(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->fixXmlConfig('connection')
            ->children()
                ->arrayNode('connections')
                    ->requiresAtLeastOneElement()
                    ->useAttributeAsKey('id')
                    ->prototype('array')
                        ->performNoDeepMerging()
                        ->children()
                            ->scalarNode('server')->end()
                            ->arrayNode('options')
                                ->performNoDeepMerging()
                                ->children()
                                    ->enumNode('authMechanism')
                                        ->values(['SCRAM-SHA-1', 'MONGODB-CR', 'MONGODB-X509', 'PLAIN', 'GSSAPI'])
                                    ->end()
                                    ->integerNode('connectTimeoutMS')->end()
                                    ->scalarNode('db')->end()
                                    ->scalarNode('authSource')
                                        ->validate()->ifNull()->thenUnset()->end()
                                    ->end()
                                    ->booleanNode('journal')->end()
                                    ->scalarNode('password')
                                        ->validate()->ifNull()->thenUnset()->end()
                                    ->end()
                                    ->enumNode('readPreference')
                                        ->values(['primary', 'primaryPreferred', 'secondary', 'secondaryPreferred', 'nearest'])
                                    ->end()
                                    ->arrayNode('readPreferenceTags')
                                        ->performNoDeepMerging()
                                        ->prototype('array')
                                            ->beforeNormalization()
                                                // Handle readPreferenceTag XML nodes
                                                ->ifTrue(static function ($v) {
                                                    return isset($v['readPreferenceTag']);
                                                })
                                                ->then(static function ($v) {
                                                    // Equivalent of fixXmlConfig() for inner node
                                                    if (isset($v['readPreferenceTag']['name'])) {
                                                        $v['readPreferenceTag'] = [$v['readPreferenceTag']];
                                                    }

                                                    return $v['readPreferenceTag'];
                                                })
                                            ->end()
                                            ->useAttributeAsKey('name')
                                            ->prototype('scalar')->end()
                                        ->end()
                                    ->end()
                                    ->scalarNode('replicaSet')
                                        ->validate()
                                            ->ifNull()->thenUnset()
                                        ->end()
                                        ->validate()
                                            ->ifTrue(static function ($v) {
                                                return ! is_string($v) && $v !== null;
                                            })->thenInvalid('The replicaSet option must be a string or null.')
                                        ->end()
                                    ->end()
                                    ->integerNode('socketTimeoutMS')->end()
                                    ->booleanNode('ssl')->end()
                                    ->scalarNode('username')
                                        ->validate()->ifNull()->thenUnset()->end()
                                    ->end()
                                    ->scalarNode('w')->end()
                                    ->integerNode('wTimeoutMS')->end()
                                    // Deprecated options
                                    ->booleanNode('fsync')->info('Deprecated. Please use the "journal" option instead.')->end()
                                    ->booleanNode('slaveOkay')->info('Deprecated. Please use the "readPreference" option instead.')->end()
                                    ->integerNode('timeout')->info('Deprecated. Please use the "connectTimeoutMS" option instead.')->end()
                                    ->integerNode('wTimeout')->info('Deprecated. Please use the "wTimeoutMS" option instead.')->end()
                                ->end()
                                ->validate()
                                    ->ifTrue(static function ($v) {
                                        return count($v['readPreferenceTags']) === 0;
                                    })
                                    ->then(static function ($v) {
                                        unset($v['readPreferenceTags']);

                                        return $v;
                                    })
                                ->end()
                            ->end()
                            ->arrayNode('driver_options')
                                ->performNoDeepMerging()
                                ->children()
                                    ->scalarNode('context')->defaultNull()->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
1164868
public function configure(ArrayNodeDefinition $builder)
  {
    $builder
      ->addDefaultsIfNotSet()
      ->children()
        ->arrayNode('templates')
          ->children()
            ->scalarNode("dir")->defaultNull()->end()
            ->scalarNode("file")->defaultValue("default.twig")->end()
          ->end()
        ->end()
        ->arrayNode('output')
          ->children()
            ->scalarNode("dir")->defaultNull()->end()
            ->scalarNode("file")->isRequired()->end()
          ->end()
        ->end()
        ->end()
    ->end();
  }
1054941
private function prepareNode(&$node, $key)
    {
        if (!isset($node[$key])) {
            $node[$key] = null;
        } elseif (!is_array($node[$key])) {
            $node[$key] = [$node[$key]];
        }
    }
242715
final public function addUserSysConfig(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->scalarNode('db_driver')
                    ->defaultValue('orm')
                    ->validate()
                        ->ifNotInArray(self::$supportedDrivers)
                        ->thenInvalid('The driver %s is not supported. Please choose one of: '.implode(',', self::$supportedDrivers))
                    ->end()
                ->end()
                ->booleanNode('use_listener')->defaultTrue()->end()
                ->scalarNode('path')->defaultNull()->end()
                ->scalarNode('host')->defaultNull()->end()
                ->scalarNode('request_matcher')->defaultNull()->end()
                ->scalarNode('user_class')->isRequired()->cannotBeEmpty()->end()
                ->scalarNode('services_prefix')
                    ->defaultNull()
                    ->validate()
                        ->ifInArray(array('fos_user'))
                        ->thenInvalid('service_service can not be "fos_user" as its already used.')
                    ->end()
                ->end()
                ->scalarNode('routes_prefix')->defaultNull()->end()
                ->scalarNode('firewall_name')->defaultNull()->end()
                ->scalarNode('model_manager_name')->defaultValue('default')->end()
                ->booleanNode('use_username_form_type')->defaultTrue()->end()
                ->arrayNode('from_email')
                    ->children()
                        ->scalarNode('address')->defaultNull()->end()
                        ->scalarNode('sender_name')->defaultNull()->end()
                    ->end()
                ->end()
            ->end()
            ->validate()
                ->ifTrue(function ($v) { return null === $v['request_matcher'] && null === $v['host'] && null === $v['path']; })
                ->thenInvalid('You need to specify a "request_matcher" service-id or "host" and/or url "path" for the discriminator.')
            ->end()
        ;

        $this->addSecuritySection($rootNode);
        $this->addServiceSection($rootNode);
        $this->addTemplateSection($rootNode);

        $this->addProfileSection($rootNode);
        $this->addChangePasswordSection($rootNode);
        $this->addRegistrationSection($rootNode);
        $this->addResettingSection($rootNode);
        $this->addGroupSection($rootNode);

        return $rootNode;
    }
783936
public function build(RootNode &$root)
    {
        $parser = new RoutingRuleParser($this->routing_rule);
        
        try{
            $section_list_set = $parser->parse();
        }
        catch(RoutingRuleParseException $e){
            throw new RouterNodeBuilderException($this->routing_rule, 'Parse failed');
        }
        
        $node = $root;
        
        foreach($section_list_set as $section_list){
            while(($section = array_shift($section_list))!==null) {
                $last = empty($section_list);
                if (is_string($section)){
                    if ($last){
                        $node->leaf($section)->bind($this->filter, $this->event);
                        break;
                    }
                    $node = $node->node($section);
                }
                else if (is_array($section)){
                    $varname = $section['varname'] ?? null;
                    $regex = $section['regex'] ?? null;
                    $type = $section['type'] ?? null;
                    $regex = empty($regex) ? '.*' : $regex;
                    if ($last){
                        $node->leaf($regex,$varname,$type)->bind($this->filter, $this->event);
                        break;
                    }
                    $node = $node->node($regex,$varname,$type);
                }
                else if ($section instanceof EmptyRoutingPathInterface){
                    if ($last){
                        $node->leaf('()')->bind($this->filter, $this->event);
                        break;
                    }
                    throw new RouterNodeBuilderException($this->routing_rule, 'Empty section not allowed before last section');
                }
                else{
                    throw new RouterNodeBuilderException($this->routing_rule, 'invalid section');
                }
            }
        }
    }
1330021
private function treatFieldsDefaultAccess(ArrayNodeDefinition $node): void
    {
        $node->validate()
            ->ifTrue(function ($v) {
                return \array_key_exists('fieldsDefaultAccess', $v) && null !== $v['fieldsDefaultAccess'];
            })
            ->then(function ($v) {
                foreach ($v['fields'] as &$field) {
                    if (\array_key_exists('access', $field) && null !== $field['access']) {
                        continue;
                    }

                    $field['access'] = $v['fieldsDefaultAccess'];
                }

                return $v;
            })
        ->end();
    }
548620
private function addUserInterfaceNode(ArrayNodeDefinition $rootNode)
    {
        $validate = function (string $interface) {

            $class = new \ReflectionClass(\str_replace(':', '\\Entity\\', $interface));

            return !$class->implementsInterface(UserInterface::class);
        };

        $rootNode->children()->variableNode('user_provider')
            ->info('The user provider entity')
            ->isRequired()
            ->validate()
            ->ifTrue($validate)
            ->thenInvalid('%s isn\'t a valid user provider.')
            ->end()
            ->end();

        return $rootNode;
    }
321422
public function setChildNodes(array $childNodes)
    {
        $rootNode = $this->objectManager->get(RootNode::class);
        foreach ($childNodes as $childNode) {
            $rootNode->addChildNode($childNode);
        }
        $this->widgetContext->setViewHelperChildNodes($rootNode, $this->renderingContext);
    }