Version 1
[yaffs-website] / web / core / modules / language / src / Plugin / LanguageNegotiation / LanguageNegotiationUI.php
1 <?php
2
3 namespace Drupal\language\Plugin\LanguageNegotiation;
4
5 use Drupal\language\LanguageNegotiationMethodBase;
6 use Symfony\Component\HttpFoundation\Request;
7
8 /**
9  * Identifies the language from the interface text language selected for page.
10  *
11  * @LanguageNegotiation(
12  *   id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI::METHOD_ID,
13  *   types = {Drupal\Core\Language\LanguageInterface::TYPE_CONTENT},
14  *   weight = 9,
15  *   name = @Translation("Interface"),
16  *   description = @Translation("Use the detected interface language.")
17  * )
18  */
19 class LanguageNegotiationUI extends LanguageNegotiationMethodBase {
20
21   /**
22    * The language negotiation method id.
23    */
24   const METHOD_ID = 'language-interface';
25
26   /**
27    * {@inheritdoc}
28    */
29   public function getLangcode(Request $request = NULL) {
30     return $this->languageManager ? $this->languageManager->getCurrentLanguage()->getId() : NULL;
31   }
32
33 }