Neos.Neos/Classes/Service/View/NodeView.php
protected function collectChildNodeData(array &$nodes, NodeInterface $node, $nodeTypeFilter, $depth = 0, NodeInterface $untilNode = null, $recursionPointer = 1)
    {
        foreach ($node->getChildNodes($nodeTypeFilter) as $childNode) {
            if (!$this->privilegeManager->isGranted(NodeTreePrivilege::class, new NodePrivilegeSubject($childNode))) {
                continue;
            }
            /** @var NodeInterface $childNode */
            $expand = ($depth === 0 || $recursionPointer < $depth);

            if ($expand === false && $untilNode !== null && strpos($untilNode->getPath(), $childNode->getPath()) === 0 && $childNode !== $untilNode) {
                // in case $untilNode is set, and the current childNode is on the rootline of $untilNode (and not the node itself), expand the node.
                $expand = true;
            }

            switch ($this->outputStyle) {
                case self::STYLE_LIST:
                    $nodeType = $childNode->getNodeType()->getName();
                    $properties = $childNode->getProperties();
                    $properties['__contextNodePath'] = $childNode->getContextPath();
                    $properties['__workspaceName'] = $childNode->getWorkspace()->getName();
                    $properties['__nodeName'] = $childNode->getName();
                    $properties['__nodeType'] = $nodeType;
                    $properties['__title'] = $nodeType === 'Neos.Neos:Document' ? $childNode->getProperty('title') : $childNode->getLabel();
                    array_push($nodes, $properties);
                    if ($expand) {
                        $this->collectChildNodeData($nodes, $childNode, $nodeTypeFilter, $depth, $untilNode, ($recursionPointer + 1));
                    }
                    break;
                case self::STYLE_TREE:
                    $children = [];
                    $hasChildNodes = $childNode->hasChildNodes($nodeTypeFilter) === true;
                    if ($expand && $hasChildNodes) {
                        $this->collectChildNodeData($children, $childNode, $nodeTypeFilter, $depth, $untilNode, ($recursionPointer + 1));
                    }
                    array_push($nodes, $this->collectTreeNodeData($childNode, $expand, $children, $hasChildNodes));
            }
        }
    }
protected function collectChildNodeData(array &$nodes, NodeInterface $node, $nodeTypeFilter, $depth = 0, NodeInterface $untilNode = null, $recursionPointer = 1)
    {
        foreach ($node->getChildNodes($nodeTypeFilter) as $childNode) {
            if (!$this->privilegeManager->isGranted(NodeTreePrivilege::class, new NodePrivilegeSubject($childNode))) {
                continue;
            }
            /** @var NodeInterface $childNode */
            $expand = ($depth === 0 || $recursionPointer < $depth);

            if ($expand === false && $untilNode !== null && strpos($untilNode->getPath(), $childNode->getPath()) === 0 && $childNode !== $untilNode) {
                // in case $untilNode is set, and the current childNode is on the rootline of $untilNode (and not the node itself), expand the node.
                $expand = true;
            }

            switch ($this->outputStyle) {
                case self::STYLE_LIST:
                    $nodeType = $childNode->getNodeType()->getName();
                    $properties = $childNode->getProperties();
                    $properties['__contextNodePath'] = $childNode->getContextPath();
                    $properties['__workspaceName'] = $childNode->getWorkspace()->getName();
                    $properties['__nodeName'] = $childNode->getName();
                    $properties['__nodeType'] = $nodeType;
                    $properties['__title'] = $nodeType === 'Neos.Neos:Document' ? $childNode->getProperty('title') : $childNode->getLabel();
                    array_push($nodes, $properties);
                    if ($expand) {
                        $this->collectChildNodeData($nodes, $childNode, $nodeTypeFilter, $depth, $untilNode, ($recursionPointer + 1));
                    }
                    break;
                case self::STYLE_TREE:
                    $children = [];
                    $hasChildNodes = $childNode->hasChildNodes($nodeTypeFilter) === true;
                    if ($expand && $hasChildNodes) {
                        $this->collectChildNodeData($children, $childNode, $nodeTypeFilter, $depth, $untilNode, ($recursionPointer + 1));
                    }
                    array_push($nodes, $this->collectTreeNodeData($childNode, $expand, $children, $hasChildNodes));
            }
        }
    }
protected function collectChildNodeData ( array & $ nodes , NodeInterface $ node , $ nodeTypeFilter , $ depth = 0 , NodeInterface $ untilNode = null , $ recursionPointer = 1 ) { foreach ( $ node -> getChildNodes ( $ nodeTypeFilter ) as $ childNode ) { if ( ! $ this -> privilegeManager -> isGranted ( NodeTreePrivilege :: class , new NodePrivilegeSubject ( $ childNode ) ) ) { continue ; } /** @var NodeInterface $childNode */ $ expand = ( $ depth === 0 || $ recursionPointer < $ depth ) ; if ( $ expand === false && $ untilNode !== null && strpos ( $ untilNode -> getPath ( ) , $ childNode -> getPath ( ) ) === 0 && $ childNode !== $ untilNode ) { // in case $untilNode is set, and the current childNode is on the rootline of $untilNode (and not the node itself), expand the node. $ expand = true ; } switch ( $ this -> outputStyle ) { case self :: STYLE_LIST : $ nodeType = $ childNode -> getNodeType ( ) -> getName ( ) ; $ properties = $ childNode -> getProperties ( ) ; $ properties [ '__contextNodePath' ] = $ childNode -> getContextPath ( ) ; $ properties [ '__workspaceName' ] = $ childNode -> getWorkspace ( ) -> getName ( ) ; $ properties [ '__nodeName' ] = $ childNode -> getName ( ) ; $ properties [ '__nodeType' ] = $ nodeType ; $ properties [ '__title' ] = $ nodeType === 'Neos.Neos:Document' ? $ childNode -> getProperty ( 'title' ) : $ childNode -> getLabel ( ) ; array_push ( $ nodes , $ properties ) ; if ( $ expand ) { $ this -> collectChildNodeData ( $ nodes , $ childNode , $ nodeTypeFilter , $ depth , $ untilNode , ( $ recursionPointer + 1 ) ) ; } break ; case self :: STYLE_TREE : $ children = [ ] ; $ hasChildNodes = $ childNode -> hasChildNodes ( $ nodeTypeFilter ) === true ; if ( $ expand && $ hasChildNodes ) { $ this -> collectChildNodeData ( $ children , $ childNode , $ nodeTypeFilter , $ depth , $ untilNode , ( $ recursionPointer + 1 ) ) ; } array_push ( $ nodes , $ this -> collectTreeNodeData ( $ childNode , $ expand , $ children , $ hasChildNodes ) ) ; } } }
Collect node data and traverse child nodes

@param array &$nodes
@param NodeInterface $node
@param string $nodeTypeFilter
@param integer $depth levels of child nodes to fetch. 0 = unlimited
@param \Neos\ContentRepository\Domain\Model\NodeInterface $untilNode if given, expand all nodes on the rootline towards $untilNode, no matter what is defined with $depth.
@param integer $recursionPointer current recursion level
@return void
Collect node data and traverse child nodes