Example #1
0
 /**
  * Determine the page id and other details.
  *
  * @return array
  */
 private function determineJumpToInformation()
 {
     // Get the right jumpto.
     $translated = $this->metaModel->isTranslated();
     $desiredLanguage = $this->metaModel->getActiveLanguage();
     $fallbackLanguage = $this->metaModel->getFallbackLanguage();
     $jumpToPageId = '';
     $filterSettingId = '';
     if (!isset($this->jumpToCache[$desiredLanguage . '.' . $fallbackLanguage])) {
         $serviceContainer = $this->metaModel->getServiceContainer();
         foreach ((array) $this->get('jumpTo') as $jumpTo) {
             $langCode = $jumpTo['langcode'];
             // If either desired language or fallback, keep the result.
             if (!$translated || $langCode == $desiredLanguage || $langCode == $fallbackLanguage) {
                 $jumpToPageId = $jumpTo['value'];
                 $filterSettingId = $jumpTo['filter'];
                 // If the desired language, break.
                 // Otherwise try to get the desired one until all have been evaluated.
                 if ($desiredLanguage == $jumpTo['langcode']) {
                     break;
                 }
             }
         }
         $pageDetails = $this->getPageDetails($jumpToPageId);
         $filterSetting = $filterSettingId ? $serviceContainer->getFilterFactory()->createCollection($filterSettingId) : null;
         $this->jumpToCache[$desiredLanguage . '.' . $fallbackLanguage] = array('page' => $jumpToPageId, 'pageDetails' => $pageDetails, 'filter' => $filterSettingId, 'filterSetting' => $filterSetting, 'language' => $pageDetails['language'], 'label' => $this->getJumpToLabel());
     }
     return $this->jumpToCache[$desiredLanguage . '.' . $fallbackLanguage];
 }
Example #2
0
 /**
  * Get available langauges.
  *
  * @param IMetaModel $objMetaModel The metamodel.
  *
  * @return array|null|\string[]
  */
 private function getAvailableLanguages(IMetaModel $objMetaModel)
 {
     return $objMetaModel->isTranslated() && $this->get('all_langs') ? $objMetaModel->getAvailableLanguages() : array($objMetaModel->getActiveLanguage());
 }