Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConfigurableLanguageManager.php

function ConfigurableLanguageManager::getCurrentLanguage

Overrides LanguageManager::getCurrentLanguage

1 call to ConfigurableLanguageManager::getCurrentLanguage()
ConfigurableLanguageManager::init in core/modules/language/src/ConfigurableLanguageManager.php

File

core/modules/language/src/ConfigurableLanguageManager.php, line 210

Class

ConfigurableLanguageManager
Overrides default LanguageManager to provide configured languages.

Namespace

Drupal\language

Code

public function getCurrentLanguage($type = LanguageInterface::TYPE_INTERFACE) {
    if (!isset($this->negotiatedLanguages[$type])) {
        // Ensure we have a valid value for this language type.
        $this->negotiatedLanguages[$type] = $this->getDefaultLanguage();
        if ($this->negotiator && $this->isMultilingual()) {
            if (!isset($this->initializing[$type])) {
                $this->initializing[$type] = TRUE;
                $negotiation = $this->negotiator
                    ->initializeType($type);
                $this->negotiatedLanguages[$type] = reset($negotiation);
                $this->negotiatedMethods[$type] = key($negotiation);
                unset($this->initializing[$type]);
            }
            elseif ($type == LanguageInterface::TYPE_INTERFACE) {
                return new Language([
                    'id' => LanguageInterface::LANGCODE_SYSTEM,
                ]);
            }
        }
    }
    return $this->negotiatedLanguages[$type];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal