FOF30\Model\TreeModel::isSelfOrDescendantOf PHP Метод

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

Returns true if $otherNode is ourselves or if we are a descendant of $otherNode
public isSelfOrDescendantOf ( TreeModel $otherNode ) : boolean
$otherNode TreeModel
Результат boolean
    public function isSelfOrDescendantOf(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

Пример #1
0
 /**
  * Returns true if $otherNode is ourselves or we are an ancestor of $otherNode
  *
  * @codeCoverageIgnore
  * @param TreeModel $otherNode
  *
  * @return bool
  */
 public function isSelfOrAncestorOf(TreeModel $otherNode)
 {
     return $otherNode->isSelfOrDescendantOf($this);
 }