You are here

private function LanguageRequestSubscriber::setLanguageOverrides in Drupal 9

Same name and namespace in other branches
  1. 8 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()

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);
}