Skip to content

Commit

Permalink
Merge pull request #306 from Kunstmaan/fix-admin-locale-listener
Browse files Browse the repository at this point in the history
Fix admin locale listener
  • Loading branch information
jockri committed May 21, 2014
2 parents 395f68c + fcc60aa commit 0fdc297
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions EventListener/AdminLocaleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Kunstmaan\AdminBundle\EventListener;

use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Translation\TranslatorInterface;
Expand All @@ -29,24 +30,29 @@ class AdminLocaleListener implements EventSubscriberInterface
private $defaultAdminlocale;

/**
* @param SecurityContext $context
* @param SecurityContext $context
* @param TranslatorInterface $translator
* @param string $defaultAdminLocale
* @param string $defaultAdminLocale
*/
public function __construct(SecurityContext $context, TranslatorInterface $translator, $defaultAdminLocale)
{
$this->translator = $translator;
$this->context = $context;
$this->translator = $translator;
$this->context = $context;
$this->defaultAdminlocale = $defaultAdminLocale;
}

/**
* onKernelView event
* onKernelRequest
*
* @param GetResponseEvent $event
*/
public function onKernelView(GetResponseEvent $event)
public function onKernelRequest(GetResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
// return immediately
return;
}

$url = $event->getRequest()->getRequestUri();

if ($this->context->getToken()) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
class: Kunstmaan\AdminBundle\EventListener\AdminLocaleListener
arguments: ["@security.context", "@translator", "%kuma_admin.default_admin_locale%"]
tags:
- { name: kernel.event_listener, event: 'kernel.view' }
- { name: 'kernel.event_listener', event: 'kernel.request', method: 'onKernelRequest' }

kunstmaan_admin.menu.twig.extension:
class: Kunstmaan\AdminBundle\Twig\MenuTwigExtension
Expand Down

0 comments on commit 0fdc297

Please sign in to comment.