You are here

public function FullLanguageManager::getAllDefinedLanguages in Flags 8

Returns list of ALL languages including predefined and configured.

Return value

array

Overrides FullLanguageManagerInterface::getAllDefinedLanguages

File

src/FullLanguageManager.php, line 38

Class

FullLanguageManager

Namespace

Drupal\flags

Code

public function getAllDefinedLanguages() {

  // Get list of all configured languages.
  $languages = [];

  // See Drupal\language\ConfigurableLanguageManager::getLanguages() for details
  $predefined = LanguageManager::getStandardLanguageList();
  foreach ($predefined as $key => $value) {
    $languages[$key] = new TranslatableMarkup($value[0]);
  }
  $config_ids = $this->configFactory
    ->listAll('language.entity.');
  foreach ($this->configFactory
    ->loadMultiple($config_ids) as $config) {
    $data = $config
      ->get();
    $languages[$data['id']] = new TranslatableMarkup($data['label']);
  }
  asort($languages);
  return $languages;
}