Jackalope\Item::getAncestor PHP Method

getAncestor() public method

{@inheritDoc}
public getAncestor ( $depth )
    public function getAncestor($depth)
    {
        $this->checkState();
        if ($depth < 0 || $depth > $this->depth) {
            throw new ItemNotFoundException('Depth must be between 0 and ' . $this->depth . ' for this Item');
        }
        if ($depth === $this->depth) {
            return $this;
        }
        // we do not use the PathHelper as this is a special case
        $ancestorPath = '/' . implode('/', array_slice(explode('/', $this->path), 1, $depth));
        return $this->objectManager->getNodeByPath($ancestorPath);
    }