예제 #1
0
 /**
  * Get link page localization
  * @return Localization
  */
 public function getPageLocalization()
 {
     throw new \Exception('Dont use me bro.');
     if (empty($this->pageId)) {
         return;
     }
     if (!is_null($this->pageLocalization)) {
         return $this->pageLocalization;
     }
     $em = ObjectRepository::getEntityManager($this);
     $pageData = null;
     $localizationEntity = Localization::CN();
     $localeId = ObjectRepository::getLocaleManager($this)->getCurrent()->getId();
     $criteria = array('master' => $this->pageId, 'locale' => $localeId);
     // Now master page ID is stored, still the old implementation is working
     $dql = "SELECT l, m, p FROM {$localizationEntity} l\n\t\t\t\tJOIN l.master m\n\t\t\t\tLEFT JOIN l.path p\n\t\t\t\tWHERE (l.master = :master AND l.locale= :locale)\n\t\t\t\tOR l.id = :master";
     try {
         $pageData = $em->createQuery($dql)->setParameters($criteria)->getSingleResult();
     } catch (NoResultException $noResult) {
         // Special case for group page selection when no localization exists in database
         $master = $em->find(GroupPage::CN(), $this->pageId);
         if ($master instanceof GroupPage) {
             $pageData = $master->getLocalization($localeId);
         }
     }
     // Cache the result
     $this->pageLocalization = $pageData;
     return $pageData;
 }