Phalcon\Mvc\Model\Behavior\NestedSet::isDescendantOf PHP Method

isDescendantOf() public method

Determines if node is descendant of subject node.
public isDescendantOf ( Phalcon\Mvc\ModelInterface $subj ) : boolean
$subj Phalcon\Mvc\ModelInterface the subject node.
return boolean whether the node is descendant of subject node.
    public function isDescendantOf($subj)
    {
        $owner = $this->getOwner();
        $result = $owner->{$this->leftAttribute} > $subj->{$this->leftAttribute} && $owner->{$this->rightAttribute} < $subj->{$this->rightAttribute};
        if ($this->hasManyRoots) {
            $result = $result && $owner->{$this->rootAttribute} === $subj->{$this->rootAttribute};
        }
        return $result;
    }