FOF30\Model\TreeModel::isDescendantOf PHP Méthode

isDescendantOf() public méthode

Returns true if we are a descendant of $otherNode
public isDescendantOf ( TreeModel $otherNode ) : boolean
$otherNode TreeModel
Résultat boolean
    public function isDescendantOf(TreeModel $otherNode)
    {
        // Sanity checks on current node position
        if ($this->lft >= $this->rgt) {
            throw new TreeInvalidLftRgtCurrent();
        }
        if ($otherNode->lft >= $otherNode->rgt) {
            throw new TreeInvalidLftRgtOther();
        }
        return $otherNode->lft < $this->lft && $otherNode->rgt > $this->rgt;
    }

Usage Example

Exemple #1
0
 /**
  * Returns true if we are an ancestor of $otherNode
  *
  * @codeCoverageIgnore
  * @param TreeModel $otherNode
  *
  * @return bool
  */
 public function isAncestorOf(TreeModel $otherNode)
 {
     return $otherNode->isDescendantOf($this);
 }