summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-06-05 18:52:32 (GMT)
committerAlex Pott2015-06-05 18:52:32 (GMT)
commit2f370af9c5dbfd7b52639d3bd42818c21066824e (patch)
treef24832fbb30c952a337134c29e46d6fb4fa28871
parent9f4d5e84fe213c546579d0d00db7385b69fa8470 (diff)
Issue #2195573 by Xano, eiriksm, heddn, ParisLiakos, Les Lim, Pere Orga, dinarcon, xjm, alexpott: Add a dedicated @LanguageNegotiation annotation class
-rw-r--r--core/modules/language/src/Annotation/LanguageNegotiation.php82
-rw-r--r--core/modules/language/src/LanguageNegotiationMethodManager.php2
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationBrowser.php2
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSelected.php2
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php2
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php2
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php2
-rw-r--r--core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php2
-rw-r--r--core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTest.php2
-rw-r--r--core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestTs.php2
-rw-r--r--core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php2
-rw-r--r--core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php2
12 files changed, 93 insertions, 11 deletions
diff --git a/core/modules/language/src/Annotation/LanguageNegotiation.php b/core/modules/language/src/Annotation/LanguageNegotiation.php
new file mode 100644
index 0000000..92f767b
--- /dev/null
+++ b/core/modules/language/src/Annotation/LanguageNegotiation.php
@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\language\Annotation\LanguageNegotiation.
+ */
+
+namespace Drupal\language\Annotation;
+
+use Drupal\Component\Annotation\Plugin;
+
+/**
+ * Defines a language negotiation annotation object.
+ *
+ * Plugin Namespace: Plugin\LanguageNegotiation
+ *
+ * For a working example, see
+ * \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationBrowser.
+ *
+ * @see \Drupal\language\LanguageNegotiator
+ * @see \Drupal\language\LanguageNegotiationMethodManager
+ * @see \Drupal\language\LanguageNegotiationMethodInterface
+ * @see hook_language_negotiation_info_alter()
+ * @see plugin_api
+ *
+ * @Annotation
+ */
+class LanguageNegotiation extends Plugin {
+
+ /**
+ * The language negotiation plugin ID.
+ *
+ * @var string
+ */
+ public $id;
+
+ /**
+ * An array of allowed language types.
+ *
+ * If a language negotiation plugin does not specify which language types it
+ * should be used with, it will be available for all the configurable
+ * language types.
+ *
+ * @var string[]
+ * An array of language types, such as the
+ * \Drupal\Core\Language\LanguageInterface::TYPE_* constants.
+ */
+ public $types;
+
+ /**
+ * The default weight of the language negotiation plugin.
+ *
+ * @var int
+ */
+ public $weight;
+
+ /**
+ * The human-readable name of the language negotiation plugin.
+ *
+ * @ingroup plugin_translatable
+ *
+ * @var \Drupal\Core\Annotation\Translation
+ */
+ public $name;
+
+ /**
+ * The description of the language negotiation plugin.
+ *
+ * @ingroup plugin_translatable
+ *
+ * @var \Drupal\Core\Annotation\Translation
+ */
+ public $description;
+
+ /**
+ * The route pointing to the plugin's configuration page.
+ *
+ * @var string
+ */
+ public $config_route_name;
+
+}
diff --git a/core/modules/language/src/LanguageNegotiationMethodManager.php b/core/modules/language/src/LanguageNegotiationMethodManager.php
index b263ed5..cf5925e 100644
--- a/core/modules/language/src/LanguageNegotiationMethodManager.php
+++ b/core/modules/language/src/LanguageNegotiationMethodManager.php
@@ -28,7 +28,7 @@ class LanguageNegotiationMethodManager extends DefaultPluginManager {
* An object that implements ModuleHandlerInterface
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
- parent::__construct('Plugin/LanguageNegotiation', $namespaces, $module_handler, 'Drupal\language\LanguageNegotiationMethodInterface');
+ parent::__construct('Plugin/LanguageNegotiation', $namespaces, $module_handler, 'Drupal\language\LanguageNegotiationMethodInterface', 'Drupal\language\Annotation\LanguageNegotiation');
$this->cacheBackend = $cache_backend;
$this->cacheKeyPrefix = 'language_negotiation_plugins';
$this->cacheKey = 'language_negotiation_plugins';
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationBrowser.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationBrowser.php
index 00c1fde..575d4f5 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationBrowser.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationBrowser.php
@@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Class for identifying language from the browser Accept-language HTTP header.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationBrowser::METHOD_ID,
* weight = -2,
* name = @Translation("Browser"),
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSelected.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSelected.php
index c4cd150..142ce0e 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSelected.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSelected.php
@@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Class for identifying language from a selected language.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected::METHOD_ID,
* weight = 12,
* name = @Translation("Selected language"),
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php
index 0341ca0..fe9500a 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php
@@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Identify language from a request/session parameter.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSession::METHOD_ID,
* weight = -6,
* name = @Translation("Session"),
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php
index 0935d1e..14c9f75 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php
@@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Identifies the language from the interface text language selected for page.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI::METHOD_ID,
* types = {Drupal\Core\Language\LanguageInterface::TYPE_CONTENT},
* weight = 9,
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
index 91f45b5..6ea4aee 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
@@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Class for identifying language via URL prefix or domain.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::METHOD_ID,
* types = {\Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE,
* \Drupal\Core\Language\LanguageInterface::TYPE_CONTENT,
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php
index abaa6e3..f585622 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php
@@ -32,7 +32,7 @@ use Symfony\Component\HttpFoundation\Request;
* fixed. This is done by introducing a prefix or domain in the rendered
* page matching the detected interface language.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrlFallback::METHOD_ID,
* types = {Drupal\Core\Language\LanguageInterface::TYPE_URL},
* weight = 8,
diff --git a/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTest.php b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTest.php
index e9f9a27..ea78138 100644
--- a/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTest.php
+++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTest.php
@@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Class for identifying language from a selected language.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = "test_language_negotiation_method",
* weight = -10,
* name = @Translation("Test"),
diff --git a/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestTs.php b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestTs.php
index cef125c..b1f463c 100644
--- a/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestTs.php
+++ b/core/modules/language/tests/language_test/src/Plugin/LanguageNegotiation/LanguageNegotiationTestTs.php
@@ -12,7 +12,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Class for identifying language from a selected language.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = "test_language_negotiation_method_ts",
* weight = -10,
* name = @Translation("Type-specific test"),
diff --git a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php
index 623dac6..e609c39 100644
--- a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php
+++ b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php
@@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Class for identifying language from the user preferences.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = \Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUser::METHOD_ID,
* weight = -4,
* name = @Translation("User"),
diff --git a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
index 2f27bf8..b953072 100644
--- a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
+++ b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
@@ -23,7 +23,7 @@ use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
/**
* Identifies admin language from the user preferences.
*
- * @Plugin(
+ * @LanguageNegotiation(
* id = Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin::METHOD_ID,
* types = {Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE},
* weight = -10,