Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LanguageNegotiationSession.php

function LanguageNegotiationSession::getLangcode

Overrides LanguageNegotiationMethodInterface::getLangcode

File

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

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');
    if (($param = $config['parameter']) && $request) {
        if ($request->query
            ->has($param)) {
            return $request->query
                ->get($param);
        }
        if ($request->getSession()
            ->has($param)) {
            return $request->getSession()
                ->get($param);
        }
    }
    return NULL;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal