From 2f370af9c5dbfd7b52639d3bd42818c21066824e Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 5 Jun 2015 19:52:32 +0100 Subject: [PATCH] Issue #2195573 by Xano, eiriksm, heddn, ParisLiakos, Les Lim, Pere Orga, dinarcon, xjm, alexpott: Add a dedicated @LanguageNegotiation annotation class --- .../src/Annotation/LanguageNegotiation.php | 82 +++++++++++++++++++ .../src/LanguageNegotiationMethodManager.php | 2 +- .../LanguageNegotiationBrowser.php | 2 +- .../LanguageNegotiationSelected.php | 2 +- .../LanguageNegotiationSession.php | 2 +- .../LanguageNegotiationUI.php | 2 +- .../LanguageNegotiationUrl.php | 2 +- .../LanguageNegotiationUrlFallback.php | 2 +- .../LanguageNegotiationTest.php | 2 +- .../LanguageNegotiationTestTs.php | 2 +- .../LanguageNegotiationUser.php | 2 +- .../LanguageNegotiationUserAdmin.php | 2 +- 12 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 core/modules/language/src/Annotation/LanguageNegotiation.php diff --git a/core/modules/language/src/Annotation/LanguageNegotiation.php b/core/modules/language/src/Annotation/LanguageNegotiation.php new file mode 100644 index 00000000000..92f767bb2a8 --- /dev/null +++ b/core/modules/language/src/Annotation/LanguageNegotiation.php @@ -0,0 +1,82 @@ +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 00c1fde6068..575d4f599f3 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 c4cd150b3b4..142ce0e05ac 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 0341ca0d35c..fe9500a4a0c 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 0935d1ed41c..14c9f759deb 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 91f45b5b1ca..6ea4aee76e8 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 abaa6e39051..f585622cf83 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 e9f9a2723d1..ea78138f1e3 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 cef125c804b..b1f463c3e07 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 623dac6dc3c..e609c39a854 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 2f27bf895c6..b95307234ac 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,