You are here

public function LanguageNegotiationContentEntity::getLangcode in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::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

1 call to LanguageNegotiationContentEntity::getLangcode()
LanguageNegotiationContentEntity::processOutbound in core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php
Processes the outbound path.

File

core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php, line 98
Contains \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity.

Class

LanguageNegotiationContentEntity
Class for identifying the content translation language.

Namespace

Drupal\language\Plugin\LanguageNegotiation

Code

public function getLangcode(Request $request = NULL) {
  $langcode = $request
    ->get(static::QUERY_PARAMETER);
  $language_enabled = array_key_exists($langcode, $this->languageManager
    ->getLanguages());
  return $language_enabled ? $langcode : NULL;
}