src/Kunstmaan/NodeBundle/Repository/NodeRepository.php
public function getAllParents(Node $node = null, $lang = null)
    {
        if (is_null($node)) {
            return array();
        }

        $qb = $this->createQueryBuilder('node');

        // Directly hydrate the nodeTranslation and nodeVersion
        $qb->select('node', 't', 'v')
            ->innerJoin('node.nodeTranslations', 't')
            ->leftJoin(
                't.publicNodeVersion',
                'v',
                'WITH',
                't.publicNodeVersion = v.id'
            )
            ->where('node.deleted = 0');

        if ($lang) {
            $qb->andWhere('t.lang = :lang')
                ->setParameter('lang', $lang);
        }

        $qb->andWhere(
            $qb->expr()->andX(
                $qb->expr()->lte('node.lft', $node->getLeft()),
                $qb->expr()->gte('node.rgt', $node->getRight())
            )
        );

        $qb->addOrderBy('node.lft', 'ASC');

        return $qb->getQuery()->getResult();
    }
public function getAllParents(Node $node = null, $lang = null)
    {
        if (is_null($node)) {
            return array();
        }

        $qb = $this->createQueryBuilder('node');

        // Directly hydrate the nodeTranslation and nodeVersion
        $qb->select('node', 't', 'v')
            ->innerJoin('node.nodeTranslations', 't')
            ->leftJoin(
                't.publicNodeVersion',
                'v',
                'WITH',
                't.publicNodeVersion = v.id'
            )
            ->where('node.deleted = 0');

        if ($lang) {
            $qb->andWhere('t.lang = :lang')
                ->setParameter('lang', $lang);
        }

        $qb->andWhere(
            $qb->expr()->andX(
                $qb->expr()->lte('node.lft', $node->getLeft()),
                $qb->expr()->gte('node.rgt', $node->getRight())
            )
        );

        $qb->addOrderBy('node.lft', 'ASC');

        return $qb->getQuery()->getResult();
    }
public function getAllParents ( Node $ node = null , $ lang = null ) { if ( is_null ( $ node ) ) { return array ( ) ; } $ qb = $ this -> createQueryBuilder ( 'node' ) ; // Directly hydrate the nodeTranslation and nodeVersion $ qb -> select ( 'node' , 't' , 'v' ) -> innerJoin ( 'node.nodeTranslations' , 't' ) -> leftJoin ( 't.publicNodeVersion' , 'v' , 'WITH' , 't.publicNodeVersion = v.id' ) -> where ( 'node.deleted = 0' ) ; if ( $ lang ) { $ qb -> andWhere ( 't.lang = :lang' ) -> setParameter ( 'lang' , $ lang ) ; } $ qb -> andWhere ( $ qb -> expr ( ) -> andX ( $ qb -> expr ( ) -> lte ( 'node.lft' , $ node -> getLeft ( ) ) , $ qb -> expr ( ) -> gte ( 'node.rgt' , $ node -> getRight ( ) ) ) ) ; $ qb -> addOrderBy ( 'node.lft' , 'ASC' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Get all parents of a given node. We can go multiple levels up.

@param Node   $node
@param string $lang

@return Node[]
Get all parents of a given node . We can go multiple levels up .