You are here

public function LanguageNegotiationSession::getLangcode in Drupal 10

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

File

core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php, line 55

Class

LanguageNegotiationSession
Identify language from a request/session parameter.

Namespace

Drupal\language\Plugin\LanguageNegotiation

Code

public function getLangcode(Request $request = NULL) {
  $config = $this->config
    ->get('language.negotiation')
    ->get('session');
  $param = $config['parameter'];
  $langcode = $request && $request->query
    ->get($param) ? $request->query
    ->get($param) : NULL;
  if (!$langcode && isset($_SESSION[$param])) {
    $langcode = $_SESSION[$param];
  }
  return $langcode;
}