public function findPagesOfMenu($menuName, $lang = NULL)
    {
        $query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p JOIN p.menu m WHERE m.label=:menuName ORDER BY m.position');
        $query->setParameter('menuName', $menuName);
        $results = $query->getResult();
        if (!is_null($lang) && isset($results[0]) && $results[0]->getLang() != $lang)
        {
            $tmp = array();
            foreach ($results as $result)
            {
               $tmp[] = $result->getId();
            }
            $query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p WHERE p.lang=:lang AND p.source_id IN (:source_ids)');
            $query->setParameter('lang', $lang);
            $query->setParameter('source_ids', $tmp);
            $results2 = $query->getResult();
            $tmp2 = array();
            foreach ($results as $result)
            {
                foreach ($results2 as $result2)
                {
                    if ($result->getId() == $result2->getSourceId())
                    {
                        $tmp2[] = $result2;
                        break;
                    }
                }
            }
            return $tmp2;
        }
        return $results;
    }
public function findPagesOfMenu($menuName, $lang = NULL)
    {
        $query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p JOIN p.menu m WHERE m.label=:menuName ORDER BY m.position');
        $query->setParameter('menuName', $menuName);
        $results = $query->getResult();
        if (!is_null($lang) && isset($results[0]) && $results[0]->getLang() != $lang)
        {
            $tmp = array();
            foreach ($results as $result)
            {
               $tmp[] = $result->getId();
            }
            $query = $this->getEntityManager()->createQuery('SELECT p FROM FulgurioLightCMSBundle:Page p WHERE p.lang=:lang AND p.source_id IN (:source_ids)');
            $query->setParameter('lang', $lang);
            $query->setParameter('source_ids', $tmp);
            $results2 = $query->getResult();
            $tmp2 = array();
            foreach ($results as $result)
            {
                foreach ($results2 as $result2)
                {
                    if ($result->getId() == $result2->getSourceId())
                    {
                        $tmp2[] = $result2;
                        break;
                    }
                }
            }
            return $tmp2;
        }
        return $results;
    }
public function findPagesOfMenu ( $ menuName , $ lang = NULL ) { $ query = $ this -> getEntityManager ( ) -> createQuery ( 'SELECT p FROM FulgurioLightCMSBundle:Page p JOIN p.menu m WHERE m.label=:menuName ORDER BY m.position' ) ; $ query -> setParameter ( 'menuName' , $ menuName ) ; $ results = $ query -> getResult ( ) ; if ( ! is_null ( $ lang ) && isset ( $ results [ 0 ] ) && $ results [ 0 ] -> getLang ( ) != $ lang ) { $ tmp = array ( ) ; foreach ( $ results as $ result ) { $ tmp [ ] = $ result -> getId ( ) ; } $ query = $ this -> getEntityManager ( ) -> createQuery ( 'SELECT p FROM FulgurioLightCMSBundle:Page p WHERE p.lang=:lang AND p.source_id IN (:source_ids)' ) ; $ query -> setParameter ( 'lang' , $ lang ) ; $ query -> setParameter ( 'source_ids' , $ tmp ) ; $ results2 = $ query -> getResult ( ) ; $ tmp2 = array ( ) ; foreach ( $ results as $ result ) { foreach ( $ results2 as $ result2 ) { if ( $ result -> getId ( ) == $ result2 -> getSourceId ( ) ) { $ tmp2 [ ] = $ result2 ; break ; } } } return $ tmp2 ; } return $ results ; }
Get page from a given menu name

@param string $menuName
@param string $lang
@return array
@todo : may be if we use a well join for source_id
Get page from a given menu name