public function getAncestors(Page $page, $depth = null, $includeNode = false)
    {
        $q = $this->createQueryBuilder('p')
                ->andIsAncestorOf($page, !$includeNode, null === $depth ? null : $page->getLevel() - $depth);

        $results = $q->orderBy($q->getSectionAlias().'._leftnode', 'asc')
                ->getQuery()
                ->getResult();

        if (true === $includeNode && false === $page->hasMainSection()) {
            $results[] = $page;
        }

        return $results;
    }
public function getAncestors(Page $page, $depth = null, $includeNode = false)
    {
        $q = $this->createQueryBuilder('p')
                ->andIsAncestorOf($page, !$includeNode, null === $depth ? null : $page->getLevel() - $depth);

        $results = $q->orderBy($q->getSectionAlias().'._leftnode', 'asc')
                ->getQuery()
                ->getResult();

        if (true === $includeNode && false === $page->hasMainSection()) {
            $results[] = $page;
        }

        return $results;
    }
public function getAncestors ( Page $ page , $ depth = null , $ includeNode = false ) { $ q = $ this -> createQueryBuilder ( 'p' ) -> andIsAncestorOf ( $ page , ! $ includeNode , null === $ depth ? null : $ page -> getLevel ( ) - $ depth ) ; $ results = $ q -> orderBy ( $ q -> getSectionAlias ( ) . '._leftnode' , 'asc' ) -> getQuery ( ) -> getResult ( ) ; if ( true === $ includeNode && false === $ page -> hasMainSection ( ) ) { $ results [ ] = $ page ; } return $ results ; }
Returns the ancestors of the provided page.

@param  Page                 $page               The page to look for ancestors.
@param  integer|null         $depth              Optional, limits results to ancestors from $depth number of generation.
@param  boolean              $includeNode        Optional, include the node itsef to results if true (false by default).

@return Page[]                                   An array of matching ancestors.
Returns the ancestors of the provided page .