public function LanguageNegotiationSession::getLangcode in Drupal 9
Same name and namespace in other branches
- 8 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSession::getLangcode()
Performs language negotiation.
Parameters
\Symfony\Component\HttpFoundation\Request $request: (optional) The current request. Defaults to NULL if it has not been initialized yet.
Return value
string A valid language code or FALSE if the negotiation was unsuccessful.
Overrides LanguageNegotiationMethodInterface::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\LanguageNegotiationCode
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;
}