vendor/ibexa/core/src/bundle/Core/EventSubscriber/CrowdinRequestLocaleSubscriber.php line 28

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. namespace Ibexa\Bundle\Core\EventSubscriber;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\HttpKernel\Event\RequestEvent;
  9. use Symfony\Component\HttpKernel\KernelEvents;
  10. /**
  11.  * If the request has an `ez_in_context_translation` cookie, sets the request accept-language
  12.  * to the pseudo-locale used to trigger Crowdin's in-context translation UI.
  13.  */
  14. class CrowdinRequestLocaleSubscriber implements EventSubscriberInterface
  15. {
  16.     public static function getSubscribedEvents()
  17.     {
  18.         return [
  19.             KernelEvents::REQUEST => [
  20.                 ['setInContextAcceptLanguage'100],
  21.             ],
  22.         ];
  23.     }
  24.     public function setInContextAcceptLanguage(RequestEvent $e)
  25.     {
  26.         if (!$e->getRequest()->cookies->has('ez_in_context_translation')) {
  27.             return;
  28.         }
  29.         $e->getRequest()->headers->set('accept-language''ach-UG');
  30.     }
  31. }
  32. class_alias(CrowdinRequestLocaleSubscriber::class, 'eZ\Bundle\EzPublishCoreBundle\EventSubscriber\CrowdinRequestLocaleSubscriber');