/** * gets next sibling or null * * @return Node */ public function getNextSibling() { // If parent and children are already loaded, avoid database query if ($this->parent !== null && ($children = $this->parent->internalGetChildren()) !== null) { for ($i = 0; $i < count($children); $i++) { if ($children[$i] == $this) { return $i + 1 >= count($children) ? null : $children[$i + 1]; } } // @codeCoverageIgnoreStart } // @codeCoverageIgnoreEnd $qb = $this->getManager()->getConfiguration()->getBaseQueryBuilder(); $alias = $this->getManager()->getConfiguration()->getQueryBuilderAlias(); $qb->andWhere("{$alias}." . $this->getLeftFieldName() . " = :lft1")->setParameter('lft1', $this->getRightValue() + 1); if ($this->hasManyRoots()) { $qb->andWhere("{$alias}." . $this->getRootFieldName() . " = :root")->setParameter('root', $this->getRootValue()); } $q = $qb->getQuery(); if ($this->getManager()->getConfiguration()->isQueryHintSet()) { $q = $this->getManager()->addHintToQuery($q); } $results = $q->getResult(); if (!$results) { return null; } return $this->getManager()->wrapNode($results[0]); }