function LanguageRequestSubscriber::setLanguageOverrides

Same name in other branches
  1. 8.9.x core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php \Drupal\language\EventSubscriber\LanguageRequestSubscriber::setLanguageOverrides()
  2. 10 core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php \Drupal\language\EventSubscriber\LanguageRequestSubscriber::setLanguageOverrides()
  3. 11.x core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php \Drupal\language\EventSubscriber\LanguageRequestSubscriber::setLanguageOverrides()

Sets the language for config overrides on the language manager.

2 calls to LanguageRequestSubscriber::setLanguageOverrides()
LanguageRequestSubscriber::onContainerInitializeSubrequestFinished in core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php
Initializes config overrides whenever the service container is rebuilt.
LanguageRequestSubscriber::onKernelRequestLanguage in core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php
Initializes the language manager at the beginning of the request.

File

core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php, line 88

Class

LanguageRequestSubscriber
Sets the $request property on the language manager.

Namespace

Drupal\language\EventSubscriber

Code

private function setLanguageOverrides() {
    $this->negotiator
        ->setCurrentUser($this->currentUser);
    if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) {
        $this->languageManager
            ->setNegotiator($this->negotiator);
        $this->languageManager
            ->setConfigOverrideLanguage($this->languageManager
            ->getCurrentLanguage());
    }
    // After the language manager has initialized, set the default langcode for
    // the string translations.
    $langcode = $this->languageManager
        ->getCurrentLanguage()
        ->getId();
    $this->translation
        ->setDefaultLangcode($langcode);
}

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