Skip to content

Commit fee5487

Browse files
committed
Tweaks for #1394
1 parent 7a13c86 commit fee5487

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cookbook/service_container/event_listener.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ using a special "tag":
7979
Request events, checking types
8080
------------------------------
8181

82-
A single page can make several requests, which is why when working with the
83-
``KernelEvents::REQUEST`` event, you might need to check the type of the
84-
request. This can be easily done as follow::
82+
A single page can make several requests (one mast request, and then multiple
83+
sub-requests), which is why when working with the ``KernelEvents::REQUEST``
84+
event, you might need to check the type of the request. This can be easily
85+
done as follow::
8586

8687
// src/Acme/DemoBundle/Listener/AcmeRequestListener.php
8788
namespace Acme\DemoBundle\Listener;
@@ -93,9 +94,12 @@ request. This can be easily done as follow::
9394
{
9495
public function onKernelRequest(GetResponseEvent $event)
9596
{
96-
if (HttpKernel::MASTER_REQUEST == $event->getRequestType()) {
97-
// Your code
97+
if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
98+
// don't do anything if it's not the master request
99+
return;
98100
}
101+
102+
// your code
99103
}
100104
}
101105

0 commit comments

Comments
 (0)