Skip to content

Commit f591e6e

Browse files
committed
feature #4532 GetResponse*Events stop after a response was set (Lumbendil)
This PR was merged into the 2.3 branch. Discussion ---------- GetResponse*Events stop after a response was set | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | All versions | Fixed tickets | #4516 The kernel.view and kernel.exception events stop propagation when a response is set, and it wasn't noted on the documentation. Commits ------- bebce0e Fix incorrect event name. e729750 Changed phrasing to explain the effects off propagation stopping. d13943a Add missing info about kernel.request event. 25e1069 Added notes specifying the propagation behaviour for kernel.view and kernel.exception.
2 parents 0de8286 + bebce0e commit f591e6e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

components/http_kernel/introduction.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ return a ``Response`` directly, or to add information to the ``Request``
167167
(e.g. setting the locale or setting some other information on the ``Request``
168168
attributes).
169169

170+
.. note::
171+
172+
When setting a response for the ``kernel.request`` event, the propagation
173+
is stopped. This means listeners with lower priority won't be executed.
174+
170175
.. sidebar:: ``kernel.request`` in the Symfony Framework
171176

172177
The most important listener to ``kernel.request`` in the Symfony Framework
@@ -391,6 +396,11 @@ At this stage, if no listener sets a response on the event, then an exception
391396
is thrown: either the controller *or* one of the view listeners must always
392397
return a ``Response``.
393398

399+
.. note::
400+
401+
When setting a response for the ``kernel.view`` event, the propagation
402+
is stopped. This means listeners with lower priority won't be executed.
403+
394404
.. sidebar:: ``kernel.view`` in the Symfony Framework
395405

396406
There is no default listener inside the Symfony Framework for the ``kernel.view``
@@ -522,6 +532,11 @@ comes with an :class:`Symfony\\Component\\HttpKernel\\EventListener\\ExceptionLi
522532
which if you choose to use, will do this and more by default (see the sidebar
523533
below for more details).
524534

535+
.. note::
536+
537+
When setting a response for the ``kernel.exception`` event, the propagation
538+
is stopped. This means listeners with lower priority won't be executed.
539+
525540
.. sidebar:: ``kernel.exception`` in the Symfony Framework
526541

527542
There are two main listeners to ``kernel.exception`` when using the

cookbook/service_container/event_listener.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ event is just one of the core kernel events::
5757
the ``kernel.exception`` event, it is :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`.
5858
To see what type of object each event listener receives, see :class:`Symfony\\Component\\HttpKernel\\KernelEvents`.
5959

60+
.. note::
61+
62+
When setting a response for the ``kernel.request``, ``kernel.view`` and
63+
``kernel.exception`` events, the propagation is stopped, so the lower
64+
priority listeners on that event don't get called.
65+
6066
Now that the class is created, you just need to register it as a service and
6167
notify Symfony that it is a "listener" on the ``kernel.exception`` event by
6268
using a special "tag":

0 commit comments

Comments
 (0)