Neos\Neos\Fusion\MenuImplementation::findParentNodeInBreadcrumbPathByLevel PHP Method

findParentNodeInBreadcrumbPathByLevel() protected method

Finds the node in the current breadcrumb path between current site node and current node whose level matches the specified entry level.
protected findParentNodeInBreadcrumbPathByLevel ( integer $givenSiteLevel, Neos\ContentRepository\Domain\Model\NodeInterface $startingPoint ) : Neos\ContentRepository\Domain\Model\NodeInterface
$givenSiteLevel integer The site level child nodes of the to be found parent node should have. See $this->entryLevel for possible values.
$startingPoint Neos\ContentRepository\Domain\Model\NodeInterface
return Neos\ContentRepository\Domain\Model\NodeInterface The parent node of the node at the specified level or NULL if none was found
    protected function findParentNodeInBreadcrumbPathByLevel($givenSiteLevel, NodeInterface $startingPoint)
    {
        $parentNode = null;
        if ($givenSiteLevel === 0) {
            return $startingPoint;
        }
        $absoluteDepth = $this->calculateNodeDepthFromRelativeLevel($givenSiteLevel, $startingPoint);
        if ($absoluteDepth - 1 > $this->getNodeLevelInSite($startingPoint)) {
            return null;
        }
        $currentSiteNode = $this->currentNode->getContext()->getCurrentSiteNode();
        $breadcrumbNodes = $currentSiteNode->getContext()->getNodesOnPath($currentSiteNode, $startingPoint);
        if (isset($breadcrumbNodes[$absoluteDepth - 1])) {
            $parentNode = $breadcrumbNodes[$absoluteDepth - 1];
        }
        return $parentNode;
    }