You are here

protected function BasicForm::getActiveLanguages in Admin User Language 8

Gets the active languages.

Return value

array Returns the active languages.

1 call to BasicForm::getActiveLanguages()
BasicForm::buildForm in src/Form/BasicForm.php
Form constructor.

File

src/Form/BasicForm.php, line 93

Class

BasicForm
Class BasicForm.

Namespace

Drupal\admin_user_language\Form

Code

protected function getActiveLanguages() {
  $languages = $this->languageManager
    ->getLanguages();
  $displayLanguages = [
    '-1' => $this
      ->t('- No preference -'),
  ];

  /** @var \Drupal\Core\Language\Language $lang */

  // Building an array of language code => language name.
  foreach ($languages as $lang) {
    $displayLanguages[$lang
      ->getId()] = $lang
      ->getName();
  }
  return $displayLanguages;
}