for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Translation\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class LocaleListener implements EventSubscriberInterface
{
public function onKernelRequest(GetResponseEvent $event)
$request = $event->getRequest();
if ($request->query->has('language') === false) {
return;
}
$locale = $request->query->get('language');
if (empty($locale) || !$locale) {
$request->setLocale($locale);
static public function getSubscribedEvents()
static
return [
// must be registered before the default Locale listener
KernelEvents::REQUEST => [['onKernelRequest', 17]],
];