src/Kunstmaan/NodeBundle/Repository/NodeRepository.php
public function getNodesByInternalName(
        $internalName,
        $lang,
        $parentId = false,
        $includeOffline = false
    ) {
        $qb = $this->createQueryBuilder('n')
            ->select('n', 't', 'v')
            ->innerJoin('n.nodeTranslations', 't')
            ->leftJoin(
                't.publicNodeVersion',
                'v',
                'WITH',
                't.publicNodeVersion = v.id'
            )
            ->where('n.deleted = 0')
            ->andWhere('n.internalName = :internalName')
            ->setParameter('internalName', $internalName)
            ->andWhere('t.lang = :lang')
            ->setParameter('lang', $lang)
            ->addOrderBy('t.weight', 'ASC')
            ->addOrderBy('t.title', 'ASC');

        if (!$includeOffline) {
            $qb->andWhere('t.online = true');
        }

        if (is_null($parentId)) {
            $qb->andWhere('n.parent is NULL');
        } elseif ($parentId === false) {
            // Do nothing
        } else {
            $qb->andWhere('n.parent = :parent')
                ->setParameter('parent', $parentId);
        }

        $query = $qb->getQuery();

        return $query->getResult();
    }
public function getNodesByInternalName(
        $internalName,
        $lang,
        $parentId = false,
        $includeOffline = false
    ) {
        $qb = $this->createQueryBuilder('n')
            ->select('n', 't', 'v')
            ->innerJoin('n.nodeTranslations', 't')
            ->leftJoin(
                't.publicNodeVersion',
                'v',
                'WITH',
                't.publicNodeVersion = v.id'
            )
            ->where('n.deleted = 0')
            ->andWhere('n.internalName = :internalName')
            ->setParameter('internalName', $internalName)
            ->andWhere('t.lang = :lang')
            ->setParameter('lang', $lang)
            ->addOrderBy('t.weight', 'ASC')
            ->addOrderBy('t.title', 'ASC');

        if (!$includeOffline) {
            $qb->andWhere('t.online = true');
        }

        if (is_null($parentId)) {
            $qb->andWhere('n.parent is NULL');
        } elseif ($parentId === false) {
            // Do nothing
        } else {
            $qb->andWhere('n.parent = :parent')
                ->setParameter('parent', $parentId);
        }

        $query = $qb->getQuery();

        return $query->getResult();
    }
public function getNodesByInternalName ( $ internalName , $ lang , $ parentId = false , $ includeOffline = false ) { $ qb = $ this -> createQueryBuilder ( 'n' ) -> select ( 'n' , 't' , 'v' ) -> innerJoin ( 'n.nodeTranslations' , 't' ) -> leftJoin ( 't.publicNodeVersion' , 'v' , 'WITH' , 't.publicNodeVersion = v.id' ) -> where ( 'n.deleted = 0' ) -> andWhere ( 'n.internalName = :internalName' ) -> setParameter ( 'internalName' , $ internalName ) -> andWhere ( 't.lang = :lang' ) -> setParameter ( 'lang' , $ lang ) -> addOrderBy ( 't.weight' , 'ASC' ) -> addOrderBy ( 't.title' , 'ASC' ) ; if ( ! $ includeOffline ) { $ qb -> andWhere ( 't.online = true' ) ; } if ( is_null ( $ parentId ) ) { $ qb -> andWhere ( 'n.parent is NULL' ) ; } elseif ( $ parentId === false ) { // Do nothing } else { $ qb -> andWhere ( 'n.parent = :parent' ) -> setParameter ( 'parent' , $ parentId ) ; } $ query = $ qb -> getQuery ( ) ; return $ query -> getResult ( ) ; }
Get an array of Nodes based on the internal name.

@param string        $internalName   The internal name of the node
@param string        $lang           The locale
@param int|null|bool $parentId       The parent id
@param bool          $includeOffline Include offline nodes

@return Node[]
Get an array of Nodes based on the internal name .