You are here

class LanguageNegotiationUI in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI

Identifies the language from the interface text language selected for page.

Plugin annotation


@LanguageNegotiation(
  id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI::METHOD_ID,
  types = {Drupal\Core\Language\LanguageInterface::TYPE_CONTENT},
  weight = 9,
  name = @Translation("Interface"),
  description = @Translation("Use the detected interface language.")
)

Hierarchy

Expanded class hierarchy of LanguageNegotiationUI

4 files declare their use of LanguageNegotiationUI
language.module in core/modules/language/language.module
Add language handling functionality to Drupal.
LanguageNegotiationInfoTest.php in core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
LanguageNegotiator.php in core/modules/language/src/LanguageNegotiator.php
language_test.module in core/modules/language/tests/language_test/language_test.module
Mock module for language layer tests.

File

core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php, line 19

Namespace

Drupal\language\Plugin\LanguageNegotiation
View source
class LanguageNegotiationUI extends LanguageNegotiationMethodBase {

  /**
   * The language negotiation method id.
   */
  const METHOD_ID = 'language-interface';

  /**
   * {@inheritdoc}
   */
  public function getLangcode(Request $request = NULL) {
    return $this->languageManager ? $this->languageManager
      ->getCurrentLanguage()
      ->getId() : NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LanguageNegotiationMethodBase::$config protected property The configuration factory.
LanguageNegotiationMethodBase::$currentUser protected property The current active user.
LanguageNegotiationMethodBase::$languageManager protected property The language manager.
LanguageNegotiationMethodBase::persist public function Notifies the plugin that the language code it returned has been accepted. Overrides LanguageNegotiationMethodInterface::persist 1
LanguageNegotiationMethodBase::setConfig public function Injects the configuration factory. Overrides LanguageNegotiationMethodInterface::setConfig
LanguageNegotiationMethodBase::setCurrentUser public function Injects the current user. Overrides LanguageNegotiationMethodInterface::setCurrentUser
LanguageNegotiationMethodBase::setLanguageManager public function Injects the language manager. Overrides LanguageNegotiationMethodInterface::setLanguageManager
LanguageNegotiationUI::getLangcode public function Performs language negotiation. Overrides LanguageNegotiationMethodInterface::getLangcode
LanguageNegotiationUI::METHOD_ID constant The language negotiation method id.