protected function CurrentLanguageResetTrait::resetLanguageContext in GraphQL 8.4
Resets the global language context across different services.
4 calls to CurrentLanguageResetTrait::resetLanguageContext()
- OperationSubscriber::onAfterOperation in src/
EventSubscriber/ OperationSubscriber.php - Handle operation end events.
- OperationSubscriber::onBeforeOperation in src/
EventSubscriber/ OperationSubscriber.php - Handle operation start events.
- SubrequestSubscriber::onKernelRequest in src/
EventSubscriber/ SubrequestSubscriber.php - Handle kernel request events.
- SubrequestSubscriber::onKernelRequestFinished in src/
EventSubscriber/ SubrequestSubscriber.php - Handle kernel request finished events.
File
- src/
EventSubscriber/ CurrentLanguageResetTrait.php, line 43
Class
- CurrentLanguageResetTrait
- Sets the current language for the current request.
Namespace
Drupal\graphql\EventSubscriberCode
protected function resetLanguageContext() : void {
if (!isset($this->languageNegotiator)) {
return;
}
if (!$this->languageManager
->isMultilingual()) {
return;
}
$this->languageNegotiator
->setCurrentUser($this->currentUser);
if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) {
$this->languageManager
->setNegotiator($this->languageNegotiator);
$this->languageManager
->setConfigOverrideLanguage($this->languageManager
->getCurrentLanguage());
}
// After the language manager has initialized, set the default langcode for
// the string translations.
if (method_exists($this->translator, 'setDefaultLangcode')) {
$language = $this->languageManager
->getCurrentLanguage()
->getId();
$this->translator
->setDefaultLangcode($language);
}
}