Skip to content

Commit

Permalink
Apply FlintCI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jo66 committed Nov 30, 2018
1 parent fae36ef commit 228afad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Action/SwitchLocaleAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

namespace Sonata\TranslationBundle\Action;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

/**
* Locale action.
Expand All @@ -30,6 +29,7 @@ final class SwitchLocaleAction
public function __invoke(Request $request, $locale)
{
$request->getSession()->set('_locale', $locale);

return new RedirectResponse($request->headers->get('referer', '/'));
}
}
7 changes: 4 additions & 3 deletions src/EventSubscriber/LocaleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Sonata\TranslationBundle\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Locale subscriber.
Expand Down Expand Up @@ -48,6 +48,7 @@ public function onKernelRequest(GetResponseEvent $event)
// try to see if the locale has been set as a _locale routing parameter
if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->set('_locale', $locale);

return;
}

Expand All @@ -60,9 +61,9 @@ public function onKernelRequest(GetResponseEvent $event)
*/
public static function getSubscribedEvents()
{
return array(
return [
// must be registered before (i.e. with a higher priority than) the default Locale listener
KernelEvents::REQUEST => [['onKernelRequest', 20]],
);
];
}
}

0 comments on commit 228afad

Please sign in to comment.