diff core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php	Wed Nov 29 16:09:58 2017 +0000
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\language\Plugin\LanguageNegotiation;
+
+use Drupal\language\LanguageNegotiationMethodBase;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Identifies the language from the interface text language selected for page.
+ *
+ * @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.")
+ * )
+ */
+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;
+  }
+
+}