Skip to content

Commit c5798e9

Browse files
authored
Merge pull request #472 from FriendsOfSymfony/emodric-sf3412_fix
Add SessionListener::onFinishRequest method to work with Symfony 3.4.12
2 parents c9d5a3b + 862ac02 commit c5798e9

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
1.3.16
5+
------
6+
7+
* Adjust session_listener to work with Symfony 3.4.12 (https://github.com/symfony/symfony/pull/27467).
8+
49
1.3.15
510
------
611

EventListener/SessionListener.php

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
16+
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
1617
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1718
use Symfony\Component\HttpKernel\EventListener\SessionListener as BaseSessionListener;
1819

@@ -78,6 +79,12 @@ public function onKernelResponse(FilterResponseEvent $event)
7879
// noop, see class description
7980
}
8081

82+
public function onFinishRequest(FinishRequestEvent $event)
83+
{
84+
// this hook has been added in symfony 3.4.12 - older versions of the listener do not register for it
85+
$this->inner->onFinishRequest($event);
86+
}
87+
8188
public static function getSubscribedEvents()
8289
{
8390
return BaseSessionListener::getSubscribedEvents();

Tests/Unit/EventListener/SessionListenerTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@ public function testOnKernelRequestRemainsUntouched()
4747
$listener->onKernelRequest($event);
4848
}
4949

50+
public function testOnFinishRequestRemainsUntouched()
51+
{
52+
if (!method_exists('Symfony\Component\HttpKernel\EventListener\SessionListener', 'onFinishRequest')) {
53+
$this->markTestSkipped('Method onFinishRequest does not exist on Symfony\Component\HttpKernel\EventListener\SessionListener');
54+
}
55+
56+
$event = $this
57+
->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')
58+
->disableOriginalConstructor()
59+
->getMock();
60+
61+
$inner = $this
62+
->getMockBuilder('Symfony\Component\HttpKernel\EventListener\SessionListener')
63+
->disableOriginalConstructor()
64+
->getMock();
65+
66+
$inner
67+
->expects($this->once())
68+
->method('onFinishRequest')
69+
->with($event)
70+
;
71+
72+
$listener = $this->getListener($inner);
73+
$listener->onFinishRequest($event);
74+
}
75+
5076
/**
5177
* @dataProvider onKernelResponseProvider
5278
*/

0 commit comments

Comments
 (0)