You are here

public function GraphQLLanguageContext::getCurrentLanguage in GraphQL 8.3

Retrieve the current language.

Return value

string|null The current language code, or null if the context is not active.

File

src/GraphQLLanguageContext.php, line 65

Class

GraphQLLanguageContext
Simple service that stores the current GraphQL language state.

Namespace

Drupal\graphql

Code

public function getCurrentLanguage() {
  return $this->isActive ? $this->currentLanguage ?: $this->languageManager
    ->getDefaultLanguage()
    ->getId() : NULL;
}