You are here

public function LanguageNegotiationContentEntity::getLangcode in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getLangcode()
  2. 9 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getLangcode()

File

core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php, line 92

Class

LanguageNegotiationContentEntity
Class for identifying the content translation language.

Namespace

Drupal\language\Plugin\LanguageNegotiation

Code

public function getLangcode(Request $request = NULL) {
  $langcode = $request->query
    ->get(static::QUERY_PARAMETER);
  $language_enabled = array_key_exists($langcode, $this->languageManager
    ->getLanguages());
  return $language_enabled ? $langcode : NULL;
}