You are here

public function TestLanguageNegotiator::getLangcode in Language Selection Page 8.2

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 LanguageNegotiationUrl::getLangcode

File

tests/modules/src/Plugin/LanguageNegotiation/TestLanguageNegotiator.php, line 36

Class

TestLanguageNegotiator
Test language negotiator.

Namespace

Drupal\language_selection_page_test\Plugin\LanguageNegotiation

Code

public function getLangcode(?Request $request = NULL) {
  $request_path = urldecode(trim($request
    ->getPathInfo(), '/'));
  if (strpos($request_path, '-fake') !== FALSE) {
    return 'fake';
  }
  return NULL;
}