From 81a5bbe82d4069407b633bf39159cf2459f75293 Mon Sep 17 00:00:00 2001 From: Bertrand Dunogier Date: Thu, 19 Jan 2017 11:36:36 +0100 Subject: [PATCH] Moved the EventSubscriber to ezpublish-kernel --- .../CrowdinRequestLocaleSubscriber.php | 31 ------------ Resources/config/services.yml | 5 -- .../CrowdinRequestLocaleSubscriberTest.php | 50 ------------------- 3 files changed, 86 deletions(-) delete mode 100644 EventSubscriber/CrowdinRequestLocaleSubscriber.php delete mode 100644 Tests/EventSubscriber/CrowdinRequestLocaleSubscriberTest.php diff --git a/EventSubscriber/CrowdinRequestLocaleSubscriber.php b/EventSubscriber/CrowdinRequestLocaleSubscriber.php deleted file mode 100644 index f46e93774..000000000 --- a/EventSubscriber/CrowdinRequestLocaleSubscriber.php +++ /dev/null @@ -1,31 +0,0 @@ - [ - ['setInContextAcceptLanguage', 100], - ], - ]; - } - - public function setInContextAcceptLanguage(GetResponseEvent $e) - { - if (!$e->getRequest()->cookies->has('ez_in_context_translation')) { - return; - } - - $e->getRequest()->headers->set('accept-language', 'ach-UG'); - } -} diff --git a/Resources/config/services.yml b/Resources/config/services.yml index db783c259..53cbcd581 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -291,8 +291,3 @@ services: calls: - [setRequestStack, ['@request_stack']] - [setPjaxRequestMatcher, ['@ezsystems.platformui.pjax.request_matcher']] - - ezsystems.platformui.event_subscriber.crowdin_request_locale: - class: EzSystems\PlatformUIBundle\EventSubscriber\CrowdinRequestLocaleSubscriber - tags: - - {name: kernel.event_subscriber} diff --git a/Tests/EventSubscriber/CrowdinRequestLocaleSubscriberTest.php b/Tests/EventSubscriber/CrowdinRequestLocaleSubscriberTest.php deleted file mode 100644 index 50d2d455e..000000000 --- a/Tests/EventSubscriber/CrowdinRequestLocaleSubscriberTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), - $request, - HttpKernelInterface::MASTER_REQUEST - ); - - $subscriber = new CrowdinRequestLocaleSubscriber(); - $subscriber->setInContextAcceptLanguage($event); - - $this->assertEquals( - $shouldHaveCustomLocale, - 'ach_UG' === $event->getRequest()->getPreferredLanguage(), - 'The custom ach_UG locale was expected to be set by the event subscriber' - ); - } - - public function testSetRequestsProvider() - { - return [ - 'with_ez_in_context_translation_cookie' => [ - new Request([], [], [], ['ez_in_context_translation' => '1']), - true, - ], - 'without_ez_in_context_translation_cookie' => [ - new Request([], [], [], []), - false, - ], - ]; - } -}