Add configuration section

@param ArrayNodeDefinition $node
545380
public function addConfigurationSection(ArrayNodeDefinition $node)
    {
        $node
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('website_name')->cannotBeEmpty()->defaultValue('Qcm Demo')->end()
                ->arrayNode('configuration')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('max_questions')->cannotBeEmpty()->defaultValue(40)->end()
                        ->arrayNode('question_level')
                            ->useAttributeAsKey('level')
                            ->prototype('scalar')->end()
                        ->end()
                        ->scalarNode('answers_max')->cannotBeEmpty()->defaultValue(5)->end()
                        ->scalarNode('timeout')->cannotBeEmpty()->defaultValue(2400)->end()
                        ->scalarNode('time_per_question')->cannotBeEmpty()->defaultValue(60)->end()
                    ->end()
                ->end()
            ->end();
    }
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();
    }
540558
public function append(NodeDefinition $node)
    {
        if ($node instanceof ParentNodeDefinitionInterface) {
            $builder = clone $this;
            $builder->setParent(null);
            $node->setBuilder($builder);
        }

        if (null !== $this->parent) {
            $this->parent->append($node);
            // Make this builder the node parent to allow for a fluid interface
            $node->setParent($this);
        }

        return $this;
    }
3934
public function addChild(TreeNodeInterface $node): void
    {
        $this->children[] = $node;
        $this->isLeaf = false;
    }
521454
private function addCurrencySection(ArrayNodeDefinition $node)
    {
        // @codingStandardsIgnoreStart
        $node
            ->children()
                ->arrayNode('currencies')
                    ->prototype('scalar')
                    ->end()
                ->end()
                ->scalarNode('reference_currency')
                    ->isRequired()
                    ->cannotBeEmpty()
                ->end()
                ->booleanNode('enable_pair_history')
                    ->defaultValue(false)
                ->end()
                ->integerNode('decimals')
                    ->defaultValue(2)
                    ->min(0)
                ->end()
                ->scalarNode('storage')
                    ->cannotBeEmpty()
                    ->defaultValue('csv')
                    ->validate()
                    ->ifNotInArray(array('csv', 'doctrine'))
                        ->thenInvalid('Invalid storage "%s"')
                    ->end()
                ->end()
                ->scalarNode('ratio_provider')
                    ->cannotBeEmpty()
                    ->defaultValue('tbbc_money.ratio_provider.ecb')
                ->end()
                ->arrayNode('templating')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('engines')
                            ->isRequired()
                            ->requiresAtLeastOneElement()
                            ->example(array('twig'))
                            ->beforeNormalization()
                                ->ifTrue(function($v){ return !is_array($v); })
                                ->then(function($v){ return array($v); })
                            ->end()
                            ->prototype('scalar')
                                ->validate()
                                    ->ifNotInArray(array('twig', 'php'))
                                    ->thenInvalid('Only "twig" and "php" engines are supported.')
                                ->end()
                            ->end()
                            ->defaultValue(array('twig'))
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
        // @codingStandardsIgnoreEnd
    }
578359
private function addSlideShowSection(ArrayNodeDefinition $node)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $node
            ->children()
                ->arrayNode('slide_show')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('static')
                            ->defaultValue([])
                            ->useAttributeAsKey('name')
                            ->prototype('scalar')->end()
                        ->end()
                        ->arrayNode('themes')
                            ->defaultValue(AbstractType::getDefaultThemeChoices())
                            ->useAttributeAsKey('name')
                            ->prototype('scalar')->end()
                        ->end()
                        ->arrayNode('types')
                            ->defaultValue([])
                            ->useAttributeAsKey('name')
                            ->prototype('array')
                                ->children()
                                    ->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
                                    ->scalarNode('js_path')->isRequired()->cannotBeEmpty()->end()
                                    ->scalarNode('label')->isRequired()->cannotBeEmpty()->end()
                                    ->variableNode('config')->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
274961
private function addSlugifyNode(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('slugify')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('lowercase')->defaultFalse()->end()
                        ->variableNode('reg_exp')->defaultValue('/([^A-Za-z0-9\p{Thai}]|-)+/u')->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
711134
private function addIndexesSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('indexes')
                ->isRequired()
                ->requiresAtLeastOneElement()
                    ->useAttributeAsKey('key')
                    ->prototype('scalar')->end()
                ->end()
            ->end();
    }
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()
        ;
    }
1209240
protected function setupTree(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('repositories')
                    ->prototype('array')
                        ->children()
                            ->scalarNode('secret')
                                ->isRequired()
                            ->end()
                            ->scalarNode('endpoint')
                                ->isRequired()
                            ->end()
                            ->booleanNode('test')
                                ->defaultFalse();
    }
1228141
private function addSessionSection(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('session')
                    ->canBeUnset()
                    ->children()
                        ->scalarNode('client')->isRequired()->end()
                        ->scalarNode('prefix')->defaultValue('session')->end()
                        ->scalarNode('ttl')->end()
                        ->booleanNode('locking')->defaultTrue()->end()
                        ->scalarNode('spin_lock_wait')->defaultValue(150000)->end()
                    ->end()
                ->end()
            ->end();
    }
1042938
protected function addResolversSection(ArrayNodeDefinition $node, array $factories)
    {
        $resolverNodeBuilder = $node
            ->fixXmlConfig('resolver')
            ->children()
                ->arrayNode('resolvers')
                    ->useAttributeAsKey('name')
                    ->prototype('array')
                    ->performNoDeepMerging()
                    ->children()
        ;

        foreach ($factories as $name => $factory) {
            $factoryNode = $resolverNodeBuilder->arrayNode($name)->canBeUnset();

            $factory->addConfiguration($factoryNode);
        }
    }
1217441
private function addTemplates(ArrayNodeDefinition $node)
    {
        //TODO: add other templates for configuration
        $node
            ->children()
                ->arrayNode('templates')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('layout')->defaultValue('BrueryUserBundle::layout.html.twig')->end()
                        ->arrayNode('login')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('frontend')->defaultValue('BrueryUserBundle:Security:login.html.twig')->end()
                                ->scalarNode('backend')->defaultValue('BrueryUserBundle:Admin:Security/login.html.twig')->end()
                            ->end()
                        ->end()
                        ->arrayNode('resetting')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('form')->defaultValue('BrueryUserBundle:Resetting:reset.html.twig')->end()
                                ->scalarNode('form_content')->defaultValue('BrueryUserBundle:Resetting:reset_content.html.twig')->end()
                                ->scalarNode('request')->defaultValue('BrueryUserBundle:Resetting:request.html.twig')->end()
                                ->scalarNode('request_content')->defaultValue('BrueryUserBundle:Resetting:request_content.html.twig')->end()
                                ->scalarNode('password_already_requested')->defaultValue('BrueryUserBundle:Resetting:password_already_requested.html.twig')->end()
                                ->scalarNode('check_email')->defaultValue('BrueryUserBundle:Resetting:check_email.html.twig')->end()
                                ->scalarNode('email')->defaultValue('BrueryUserBundle:Resetting:email.html.twig')->end()
                            ->end()
                        ->end()
                        ->arrayNode('profile')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('show')->defaultValue('BrueryUserBundle:Profile:show.html.twig')->end()
                                ->scalarNode('action')->defaultValue('BrueryUserBundle:Profile:action.html.twig')->end()
                                ->scalarNode('edit')->defaultValue('BrueryUserBundle:Profile:edit_profile.html.twig')->end()
                                ->scalarNode('edit_content')->defaultValue('BrueryUserBundle:Profile:edit_profile_content.html.twig')->end()
                                ->scalarNode('edit_authentication')->defaultValue('BrueryUserBundle:Profile:edit_authentication.html.twig')->end()
                                ->scalarNode('edit_authentication_content')->defaultValue('BrueryUserBundle:Profile:edit_authentication_content.html.twig')->end()
                            ->end()
                        ->end()
                        ->arrayNode('registration')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('form')->defaultValue('BrueryUserBundle:Registration:register.html.twig')->end()
                                ->scalarNode('form_content')->defaultValue('BrueryUserBundle:Registration:register_content.html.twig')->end()
                                ->scalarNode('check_email')->defaultValue('BrueryUserBundle:Registration:check_email.html.twig')->end()
                                ->scalarNode('confirmed')->defaultValue('BrueryUserBundle:Registration:confirmed.html.twig')->end()
                                ->scalarNode('email')->defaultValue('BrueryUserBundle:Registration:email.html.twig')->end()
                            ->end()
                        ->end()
                        ->arrayNode('change_password')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('form')->defaultValue('BrueryUserBundle:ChangePassword:change_password.html.twig')->end()
                                ->scalarNode('form_content')->defaultValue('BrueryUserBundle:ChangePassword:change_password_content.html.twig')->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
726965
protected function addKinesisConfiguration(ArrayNodeDefinition $rootNode) {
        $rootNode->children()
            ->arrayNode('kinesis')
                ->children()
                    ->scalarNode('api_version')->defaultValue('2013-12-02')->end()
                    ->scalarNode('region')->isRequired()->end()
                    ->arrayNode('consumer')
                        ->children()
                            ->scalarNode('recovery_file')->isRequired()->end()
                            ->scalarNode('key')->isRequired()->end()
                            ->scalarNode('secret')->isRequired()->end()
                        ->end()
                    ->end()
                    ->arrayNode('producer')
                        ->children()
                            ->scalarNode('key')->isRequired()->end()
                            ->scalarNode('secret')->isRequired()->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();
  }
281333
private function addObjectsSection(ArrayNodeDefinition $node)
    {
        $node->children()
            ->arrayNode('objects')
                ->addDefaultsIfNotSet()
                ->children()
                    ->arrayNode('route')
                        ->addDefaultsIfNotSet()
                        ->children()
                            ->scalarNode('model')->defaultValue(Route::class)->end()
                            ->scalarNode('repository')->defaultValue(RouteRepository::class)->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ->end();
    }
1346869
private function addDocumentManagersSection(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->fixXmlConfig('document_manager')
            ->children()
                ->arrayNode('document_managers')
                    ->useAttributeAsKey('id')
                    ->requiresAtLeastOneElement()
                    ->prototype('array')
                        ->treatNullLike([])
                        ->fixXmlConfig('filter')
                        ->children()
                            ->scalarNode('connection')->end()
                            ->scalarNode('database')->end()
                            ->booleanNode('logging')->defaultValue('%kernel.debug%')->end()
                            ->arrayNode('profiler')
                                ->addDefaultsIfNotSet()
                                ->treatTrueLike(['enabled' => true])
                                ->treatFalseLike(['enabled' => false])
                                ->children()
                                    ->booleanNode('enabled')->defaultValue('%kernel.debug%')->end()
                                    ->booleanNode('pretty')->defaultValue('%kernel.debug%')->end()
                                ->end()
                            ->end()
                            ->scalarNode('default_document_repository_class')->defaultValue(DocumentRepository::class)->end()
                            ->scalarNode('default_gridfs_repository_class')->defaultValue(DefaultGridFSRepository::class)->end()
                            ->scalarNode('repository_factory')->defaultValue('doctrine_mongodb.odm.container_repository_factory')->end()
                            ->scalarNode('persistent_collection_factory')->defaultNull()->end()
                            ->booleanNode('auto_mapping')->defaultFalse()->end()
                            ->arrayNode('filters')
                                ->useAttributeAsKey('name')
                                ->prototype('array')
                                    ->fixXmlConfig('parameter')
                                    ->beforeNormalization()
                                        ->ifString()
                                        ->then(static function ($v) {
                                            return ['class' => $v];
                                        })
                                    ->end()
                                    ->beforeNormalization()
                                        // The content of the XML node is returned as the "value" key so we need to rename it
                                        ->ifTrue(static function ($v) {
                                            return is_array($v) && isset($v['value']);
                                        })
                                        ->then(static function ($v) {
                                            $v['class'] = $v['value'];
                                            unset($v['value']);

                                            return $v;
                                        })
                                    ->end()
                                    ->children()
                                        ->scalarNode('class')->isRequired()->end()
                                        ->booleanNode('enabled')->defaultFalse()->end()
                                        ->arrayNode('parameters')
                                            ->treatNullLike([])
                                            ->useAttributeAsKey('name')
                                            ->prototype('variable')
                                                ->beforeNormalization()
                                                    // Detect JSON object and array syntax (for XML)
                                                    ->ifTrue(static function ($v) {
                                                        return is_string($v) && (preg_match('/\[.*\]/', $v) || preg_match('/\{.*\}/', $v));
                                                    })
                                                    // Decode objects to associative arrays for consistency with YAML
                                                    ->then(static function ($v) {
                                                        return json_decode($v, true);
                                                    })
                                                ->end()
                                            ->end()
                                        ->end()
                                    ->end()
                                ->end()
                            ->end()
                            ->arrayNode('metadata_cache_driver')
                                ->addDefaultsIfNotSet()
                                ->beforeNormalization()
                                    ->ifString()
                                    ->then(static function ($v) {
                                        return ['type' => $v];
                                    })
                                ->end()
                                ->children()
                                    ->scalarNode('type')->defaultValue('array')->end()
                                    ->scalarNode('class')->end()
                                    ->scalarNode('host')->end()
                                    ->integerNode('port')->end()
                                    ->scalarNode('instance_class')->end()
                                    ->scalarNode('id')->end()
                                    ->scalarNode('namespace')->end()
                                ->end()
                            ->end()
                        ->end()
                        ->fixXmlConfig('mapping')
                        ->children()
                            ->arrayNode('mappings')
                                ->useAttributeAsKey('name')
                                ->prototype('array')
                                    ->beforeNormalization()
                                        ->ifString()
                                        ->then(static function ($v) {
                                            return ['type' => $v];
                                        })
                                    ->end()
                                    ->treatNullLike([])
                                    ->treatFalseLike(['mapping' => false])
                                    ->performNoDeepMerging()
                                    ->children()
                                        ->scalarNode('mapping')->defaultValue(true)->end()
                                        ->scalarNode('type')->end()
                                        ->scalarNode('dir')->end()
                                        ->scalarNode('prefix')->end()
                                        ->scalarNode('alias')->end()
                                        ->booleanNode('is_bundle')->end()
                                    ->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }