Neos\Neos\Service\View\NodeView::collectParentNodeData PHP Метод

collectParentNodeData() публичный Метод

public collectParentNodeData ( Neos\ContentRepository\Domain\Model\NodeInterface $rootNode, array $nodes ) : array
$rootNode Neos\ContentRepository\Domain\Model\NodeInterface
$nodes array
Результат array
    public function collectParentNodeData(NodeInterface $rootNode, array $nodes)
    {
        $nodeCollection = array();
        $addNode = function ($node, $matched) use($rootNode, &$nodeCollection) {
            /** @var NodeInterface $node */
            $path = str_replace('/', '.children.', substr($node->getPath(), strlen($rootNode->getPath()) + 1));
            if ($path !== '') {
                $nodeCollection = Arrays::setValueByPath($nodeCollection, $path . '.node', $node);
                if ($matched === true) {
                    $nodeCollection = Arrays::setValueByPath($nodeCollection, $path . '.matched', true);
                }
            }
        };
        $findParent = function ($node) use(&$findParent, &$addNode) {
            /** @var NodeInterface $node */
            $parent = $node->getParent();
            if ($parent !== null) {
                $addNode($parent, false);
                $findParent($parent);
            }
        };
        foreach ($nodes as $node) {
            $addNode($node, true);
            $findParent($node);
        }
        $treeNodes = array();
        $self = $this;
        $collectTreeNodeData = function (&$treeNodes, $node) use(&$collectTreeNodeData, $self) {
            $children = array();
            if (isset($node['children'])) {
                foreach ($node['children'] as $childNode) {
                    $collectTreeNodeData($children, $childNode);
                }
            }
            $treeNodes[] = $self->collectTreeNodeData($node['node'], true, $children, $children !== array(), isset($node['matched']));
        };
        foreach ($nodeCollection as $firstLevelNode) {
            $collectTreeNodeData($treeNodes, $firstLevelNode);
        }
        return $treeNodes;
    }