/** * Return all languages with the master one promoted to the first position * * @return Collection Languages collection */ public function getLanguagesWithMasterLanguagePromoted() { $languages = $this->languageManager->getLanguages()->toArray(); $masterLocale = $this->masterLocale->getIso(); $index = array_search($masterLocale, $languages); if (false !== $index) { $mainLanguage = $languages[$index]; unset($languages[$index]); array_unshift($languages, $mainLanguage); } return new ArrayCollection($languages); }
/** * Return all available languages * * @return array Available languages */ public function getLanguages() { $languages = $this->languageManager->getLanguages()->toArray(); return $this->promoteMasterLanguage($languages); }