8000 Tweaks · symfony/symfony@096a1e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 096a1e6

Browse files
Tweaks
1 parent c2d19ed commit 096a1e6

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\RequestStack;
1717
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
1818
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\KernelEvent;
1920
use Symfony\Component\HttpKernel\KernelEvents;
2021
use Symfony\Component\Routing\RequestContextAwareInterface;
2122

@@ -42,7 +43,7 @@ public function __construct(RequestStack $requestStack, $defaultLocale = 'en', R
4243
$this->router = $router;
4344
}
4445

45-
public function onKernelRequestEarly(GetResponseEvent $event)
46+
public function setDefaultLocale(KernelEvent $event)
4647
{
4748
$event->getRequest()->setDefaultLocale($this->defaultLocale);
4849
}
@@ -80,7 +81,7 @@ public static function getSubscribedEvents()
8081
{
8182
return array(
8283
KernelEvents::REQUEST => array(
83-
array('onKernelRequestEarly', 100),
84+
array('setDefaultLocale', 100),
8485
// must be registered after the Router to have access to the _locale
8586
array('onKernelRequest', 16),
8687
),

src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpKernel\Tests\EventListener;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1718
use Symfony\Component\HttpKernel\EventListener\LocaleListener;
@@ -29,29 +30,26 @@ protected function setUp()
2930

3031
public function testIsAnEventSubscriber()
3132
{
32-
$this->assertInstanceOf(
33-
'Symfony\Component\EventDispatcher\EventSubscriberInterface',
34-
new LocaleListener($this->requestStack)
35-
);
33+
$this->assertInstanceOf(EventSubscriberInterface::class, new LocaleListener($this->requestStack));
3634
}
3735

3836
public function testRegisteredEvent()
3937
{
4038
$this->assertEquals(
4139
array(
42-
KernelEvents::REQUEST => array(array('onKernelRequestEarly', 100), array('onKernelRequest', 16)),
40+
KernelEvents::REQUEST => array(array('setDefaultLocale', 100), array('onKernelRequest', 16)),
4341
KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)),
4442
),
4543
LocaleListener::getSubscribedEvents()
4644
);
4745
}
4846

49-
public function testDefaultLocaleWithoutSession()
47+
public function testDefaultLocale()
5048
{
5149
$listener = new LocaleListener($this->requestStack, 'fr');
5250
$event = $this->getEvent($request = Request::create('/'));
5351

54-
$listener->onKernelRequestEarly($event);
52+
$listener->setDefaultLocale($event);
5553
$this->assertEquals('fr', $request->getLocale());
5654
}
5755

0 commit comments

Comments
 (0)
0