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

Breadcrumb

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

function LanguageNegotiationContentEntity::getLangcode

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 94

Class

LanguageNegotiationContentEntity
Class for identifying the content translation language.

Namespace

Drupal\language\Plugin\LanguageNegotiation

Code

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

API Navigation

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