function LanguageManager::getLanguages

Same name in other branches
  1. 9 core/lib/Drupal/Core/Language/LanguageManager.php \Drupal\Core\Language\LanguageManager::getLanguages()
  2. 10 core/lib/Drupal/Core/Language/LanguageManager.php \Drupal\Core\Language\LanguageManager::getLanguages()
  3. 11.x core/lib/Drupal/Core/Language/LanguageManager.php \Drupal\Core\Language\LanguageManager::getLanguages()

Overrides LanguageManagerInterface::getLanguages

2 calls to LanguageManager::getLanguages()
LanguageManager::getLanguage in core/lib/Drupal/Core/Language/LanguageManager.php
Returns a language object from the given language code.
LanguageManager::getNativeLanguages in core/lib/Drupal/Core/Language/LanguageManager.php
Returns a list of languages set up on the site in their native form.
1 method overrides LanguageManager::getLanguages()
ConfigurableLanguageManager::getLanguages in core/modules/language/src/ConfigurableLanguageManager.php
Returns a list of languages set up on the site.

File

core/lib/Drupal/Core/Language/LanguageManager.php, line 123

Class

LanguageManager
Class responsible for providing language support on language-unaware sites.

Namespace

Drupal\Core\Language

Code

public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) {
    $static_cache_id = $this->getCurrentLanguage()
        ->getId();
    if (!isset($this->languages[$static_cache_id][$flags])) {
        // If this language manager is used, there are no configured languages.
        // The default language and locked languages comprise the full language
        // list.
        $default = $this->getDefaultLanguage();
        $languages = [
            $default->getId() => $default,
        ];
        $languages += $this->getDefaultLockedLanguages($default->getWeight());
        // Filter the full list of languages based on the value of $flags.
        $this->languages[$static_cache_id][$flags] = $this->filterLanguages($languages, $flags);
    }
    return $this->languages[$static_cache_id][$flags];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.