@param ArrayNodeDefinition $rootNode

@return ArrayNodeDefinition

@throws \RuntimeException
@throws \InvalidArgumentException
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;
    }
1334303
public function mapTree(array $nodes, array $mappedNodes = []) {
        if (!$mappedNodes) {
            return $nodes;
        }

        $tree = [];
        $pk = $this->getRepository()->getPrimaryKey();

        foreach ($nodes as $node) {
            $id = $node[$pk];

            if (isset($mappedNodes[$id])) {
                $node[$this->getConfig('treeField') ?: 'Nodes'] = $this->mapTree($mappedNodes[$id], $mappedNodes);
            }

            $tree[] = $node;
        }

        return $tree;
    }
1244751
public function previous(TraversableNodeInterface $referenceNode): TraversableNodeInterface
    {
        $referenceNodeIndex = $this->getNodeIndex($referenceNode);
        if ($referenceNodeIndex === 0) {
            throw new \InvalidArgumentException(sprintf('The node %s is the first node in the set, so there is no previous node.', $referenceNode->getNodeAggregateIdentifier()), 1542902422);
        }
        return $this->nodes[$referenceNodeIndex - 1];
    }
893112
public function tree($rootId, array $columns=[])
    {

        $columns = $this->pickColumns($columns);
        $columnsId = $this->getColumnsCacheId($columns);

        if (isset($this->_hierachyCache[$columnsId][$rootId])) {
            return $this->_hierachyCache[$columnsId][$rootId];
        }

        $result = $this->queryTree($rootId)
                       ->get($this->toSelectColumns($columns));

        $this->fillNodeCache($columnsId, $result);

        return $this->_rootNodeCache[$columnsId][$rootId];

    }
1208992
public function createEditForm(ContentNode $contentNode, Node $rootNode = null)
    {

        $templateVars = array(
            'action' => $this->get('router')->generate('mm_cmf_content_node_update', array(
                'id' => $contentNode->getId()
            ))
        );

        if ($rootNode)
            $templateVars['root_node'] = $rootNode;

        return $this->createForm(
            ContentNodeType::class,
            $contentNode,
            $templateVars
        );
    }
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();
    }
1037951
public function appendConfiguration(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('qa')
                    ->children()
                        ->arrayNode('phpcs')
                        ->children()
                        ->arrayNode('dir')
                        ->prototype('scalar')->end()
                        ->performNoDeepMerging()
                        ->end()
                        ->scalarNode('standard')->end()
                        ->scalarNode('options')->end()
                        ->end()
                        ->end()
                        ->arrayNode('jshint')
                        ->children()
                        ->arrayNode('files')
                        ->beforeNormalization()
                        ->ifString()->then(
                        function($v) {
                            return array_filter(array($v));
                        }
                    )
                        ->end()
                        ->prototype('scalar')->end()
                        ->performNoDeepMerging()
                        ->end()
                        ->scalarNode('run')->end()
                        ->end()
                    ->end()
                ->end()
        ->end();
    }
320217
public function getCurrentPermissionArray(ResourceNode $resourceNode)
    {
        $currentRoles = $this->tokenStorage->getToken()->getRoles();

        $roleNames = array_map(function (RoleInterface $roleName) {
            return $roleName->getRole();
        }, $currentRoles);

        $creatable = [];
        if ($this->isManager($resourceNode)) {
            /** @var ResourceType[] $resourceTypes */
            $resourceTypes = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();

            foreach ($resourceTypes as $resourceType) {
                $creatable[] = $resourceType->getName();
            }

            $perms = array_fill_keys(array_values($this->maskManager->getPermissionMap($resourceNode->getResourceType())), true);
        } else {
            $creatable = $this->getCreatableTypes($roleNames, $resourceNode);

            $perms = $this->maskManager->decodeMask(
                $this->rightsRepo->findMaximumRights($roleNames, $resourceNode),
                $resourceNode->getResourceType()
            );
        }

        return array_merge($perms, ['create' => $creatable]);
    }
71843
protected function setupTree(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->addDefaultsIfNotSet()
            ->children()
                ->arrayNode('queues')
                    ->prototype('scalar')->end()
                ->end()
                ->scalarNode('serializer')
                    ->treatNullLike('RSQueue\\Serializer\\JsonSerializer')
                    ->defaultValue('RSQueue\\Serializer\\JsonSerializer')
                ->end()
                ->arrayNode('collector')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('enable')
                            ->defaultTrue()
                        ->end()
                    ->end()
                ->end()
                ->arrayNode('server')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('redis')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->scalarNode('cluster')
                                    ->defaultFalse()
                                ->end()
                                ->scalarNode('host')
                                    ->defaultValue('127.0.0.1')
                                ->end()
                                ->scalarNode('port')
                                    ->defaultValue(6379)
                                ->end()
                                ->scalarNode('database')
                                    ->defaultNull()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
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');
                }
            }
        }
    }
1362540
private function createMappingField(\DOMNode $fieldNode)
    {
        $fieldParam = ['type' => $fieldNode->getAttribute('type')];

        if ($fieldNode->hasAttribute('nestedPath')) {
            $fieldParam['nestedPath'] = $fieldNode->getAttribute('nestedPath');
        }

        foreach ($fieldNode->childNodes as $childNode) {
            if ($childNode instanceof \DOMElement) {
                $tagName = $this->underscore($childNode->tagName);
                $fieldParam['fieldConfig'][$tagName] = $childNode->nodeValue;
            }
        }

        return $fieldParam;
    }
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;
    }
1054624
public function json($params, $rootNode = NULL)
    {
        if ( $rootNode ) {
            $params = [$rootNode => $params];
        }

        return (new Json($params))->getContent();
    }
1049687
public function setNode(?string $node): NodeAwareDefinitionInterface
    {
        if ($node && !preg_match('/\w+/', $node)) {
            throw new \InvalidArgumentException('Invalid node name');
        }

        $this->node = $node;

        return $this;
    }
108229
function addNode( $nodeID, $isSubtree = true )
    {
        $this->RootNodeIDArray[] = $nodeID;
        $this->NodeIDArray[] = $nodeID;

        if ( $isSubtree )
        {
            $nodeArray = eZContentObjectTreeNode::subTreeByNodeID( array( 'AsObject' => false ), $nodeID );
            foreach( $nodeArray as $node )
            {
                $this->NodeIDArray[] = $node['node_id'];
            }
        }
    }
21317
protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
    {
        $title = htmlspecialchars($node->getTitle());
        $element = $document->createElement(static::NODE_NAME, $title);
        $rootElement->appendChild($element);
    }
133417
public function getDocument($document, $rootNode)
	{
		if ($rootNode == null)
		{
			$rootNode = "page";
		}
		return $this->_persistUtil->getDocument($document, $rootNode);
	}