function LanguageNegotiationSession::getLangcode
Same name and namespace in other branches
- 8.9.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSession::getLangcode()
- 10 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSession::getLangcode()
- 11.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSession::getLangcode()
Performs language negotiation.
@todo Determine whether string|false or string|null should be the normalized result across all implementations and update the
Parameters
\Symfony\Component\HttpFoundation\Request $request: (optional) The current request. Defaults to NULL if it has not been initialized yet.
Return value
string|null|false A valid language code if the negotiation was successful and either NULL or FALSE otherwise.
and its comment accordingly.
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.