File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
cookbook/service_container Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,10 @@ using a special "tag":
79
79
Request events, checking types
80
80
------------------------------
81
81
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::
85
86
86
87
// src/Acme/DemoBundle/Listener/AcmeRequestListener.php
87
88
namespace Acme\DemoBundle\Listener;
@@ -93,9 +94,12 @@ request. This can be easily done as follow::
93
94
{
94
95
public function onKernelRequest(GetResponseEvent $event)
95
96
{
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;
98
100
}
101
+
102
+ // your code
99
103
}
100
104
}
101
105
You can’t perform that action at this time.
0 commit comments