public function getDescendants($depth = null)
    {
        if(!$this->hasChildren())
        {
            return array();
        }

        if($this->descendants === null)
        {
            $qb = $this->getManager()->getConfiguration()->getBaseQueryBuilder();
            $alias = $this->getManager()->getConfiguration()->getQueryBuilderAlias();

            $qb->andWhere("$alias.".$this->getLeftFieldName()." > :lft1")
                ->setParameter('lft1', $this->getLeftValue())
                ->andWhere("$alias.".$this->getRightFieldName()." < :rgt1")
                ->setParameter('rgt1', $this->getRightValue())
                ->orderBy("$alias.".$this->getLeftFieldName(), "ASC");
            if($this->hasManyRoots())
            {
                $qb->andWhere("$alias.".$this->getRootFieldName()." = :root")
                    ->setParameter('root', $this->getRootValue());
            }

            // TODO: Add depth support or self join support?
			$q = $qb->getQuery();
			if ($this->getManager()->getConfiguration()->isQueryHintSet()){
				$q = $this->getManager()->addHintToQuery($q);
			}
            $results = $q->getResult();

            $this->descendants = array();
            foreach($results as $result)
            {
                $this->descendants[] = $this->getManager()->wrapNode($result);
            }
        }

        if($depth !== null)
        {
            // TODO: Don't rebuild filtered array everytime?
            return $this->getManager()->filterNodeDepth($this->descendants, $depth);
        }

        return $this->descendants;
    }
public function getDescendants($depth = null)
    {
        if(!$this->hasChildren())
        {
            return array();
        }

        if($this->descendants === null)
        {
            $qb = $this->getManager()->getConfiguration()->getBaseQueryBuilder();
            $alias = $this->getManager()->getConfiguration()->getQueryBuilderAlias();

            $qb->andWhere("$alias.".$this->getLeftFieldName()." > :lft1")
                ->setParameter('lft1', $this->getLeftValue())
                ->andWhere("$alias.".$this->getRightFieldName()." < :rgt1")
                ->setParameter('rgt1', $this->getRightValue())
                ->orderBy("$alias.".$this->getLeftFieldName(), "ASC");
            if($this->hasManyRoots())
            {
                $qb->andWhere("$alias.".$this->getRootFieldName()." = :root")
                    ->setParameter('root', $this->getRootValue());
            }

            // TODO: Add depth support or self join support?
			$q = $qb->getQuery();
			if ($this->getManager()->getConfiguration()->isQueryHintSet()){
				$q = $this->getManager()->addHintToQuery($q);
			}
            $results = $q->getResult();

            $this->descendants = array();
            foreach($results as $result)
            {
                $this->descendants[] = $this->getManager()->wrapNode($result);
            }
        }

        if($depth !== null)
        {
            // TODO: Don't rebuild filtered array everytime?
            return $this->getManager()->filterNodeDepth($this->descendants, $depth);
        }

        return $this->descendants;
    }
public function getDescendants ( $ depth = null ) { if ( ! $ this -> hasChildren ( ) ) { return array ( ) ; } if ( $ this -> descendants === null ) { $ qb = $ this -> getManager ( ) -> getConfiguration ( ) -> getBaseQueryBuilder ( ) ; $ alias = $ this -> getManager ( ) -> getConfiguration ( ) -> getQueryBuilderAlias ( ) ; $ qb -> andWhere ( "$alias." . $ this -> getLeftFieldName ( ) . " > :lft1" ) -> setParameter ( 'lft1' , $ this -> getLeftValue ( ) ) -> andWhere ( "$alias." . $ this -> getRightFieldName ( ) . " < :rgt1" ) -> setParameter ( 'rgt1' , $ this -> getRightValue ( ) ) -> orderBy ( "$alias." . $ this -> getLeftFieldName ( ) , "ASC" ) ; if ( $ this -> hasManyRoots ( ) ) { $ qb -> andWhere ( "$alias." . $ this -> getRootFieldName ( ) . " = :root" ) -> setParameter ( 'root' , $ this -> getRootValue ( ) ) ; } // TODO: Add depth support or self join support? $ q = $ qb -> getQuery ( ) ; if ( $ this -> getManager ( ) -> getConfiguration ( ) -> isQueryHintSet ( ) ) { $ q = $ this -> getManager ( ) -> addHintToQuery ( $ q ) ; } $ results = $ q -> getResult ( ) ; $ this -> descendants = array ( ) ; foreach ( $ results as $ result ) { $ this -> descendants [ ] = $ this -> getManager ( ) -> wrapNode ( $ result ) ; } } if ( $ depth !== null ) { // TODO: Don't rebuild filtered array everytime? return $ this -> getManager ( ) -> filterNodeDepth ( $ this -> descendants , $ depth ) ; } return $ this -> descendants ; }
gets descendants for this node

@param int $depth or null for unlimited depth

@return array array of NodeWrapper objects
gets descendants for this node