Last active
January 13, 2016 08:48
-
-
Save morontt/0c6815ae546ec90b5a4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: morontt | |
* Date: 29.07.14 | |
* Time: 0:32 | |
*/ | |
namespace Avtogid\FrontendBundle\EventListener; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Avtogid\FrontendBundle\Services\Domains; | |
class LocaleListener | |
{ | |
/** | |
* @var \Avtogid\FrontendBundle\Services\Domains | |
*/ | |
protected $domains; | |
/** | |
* @param Domains $domains | |
*/ | |
public function __construct(Domains $domains) | |
{ | |
$this->domains = $domains; | |
} | |
/** | |
* @param GetResponseEvent $event | |
*/ | |
public function onKernelRequest(GetResponseEvent $event) | |
{ | |
$currentConfig = $this->domains->getCurrentDomain(); | |
$request = $event->getRequest(); | |
$request->setLocale($currentConfig['default_lang']); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
avtogid_frontend.locale_listener: | |
class: Avtogid\FrontendBundle\EventListener\LocaleListener | |
arguments: ["@avtogid.domains"] | |
tags: | |
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 10 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment