Permalink
Browse files

feature #4532 GetResponse*Events stop after a response was set (Lumbe…

…ndil)

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.
  • Loading branch information...
weaverryan committed Dec 20, 2014
2 parents 0de8286 + bebce0e commit f591e6e1d7b04faf5703dd76be10d2f8d5870dcd
Showing with 21 additions and 0 deletions.
  1. +15 −0 components/http_kernel/introduction.rst
  2. +6 −0 cookbook/service_container/event_listener.rst
@@ -167,6 +167,11 @@ return a ``Response`` directly, or to add information to the ``Request``
(e.g. setting the locale or setting some other information on the ``Request``
attributes).
.. note::
When setting a response for the ``kernel.request`` event, the propagation
is stopped. This means listeners with lower priority won't be executed.
.. sidebar:: ``kernel.request`` in the Symfony Framework
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
is thrown: either the controller *or* one of the view listeners must always
return a ``Response``.
.. note::
When setting a response for the ``kernel.view`` event, the propagation
is stopped. This means listeners with lower priority won't be executed.
.. sidebar:: ``kernel.view`` in the Symfony Framework
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
which if you choose to use, will do this and more by default (see the sidebar
below for more details).
.. note::
When setting a response for the ``kernel.exception`` event, the propagation
is stopped. This means listeners with lower priority won't be executed.
.. sidebar:: ``kernel.exception`` in the Symfony Framework
There are two main listeners to ``kernel.exception`` when using the
@@ -57,6 +57,12 @@ event is just one of the core kernel events::
the ``kernel.exception`` event, it is :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`.
To see what type of object each event listener receives, see :class:`Symfony\\Component\\HttpKernel\\KernelEvents`.
.. note::
When setting a response for the ``kernel.request``, ``kernel.view`` and
``kernel.exception`` events, the propagation is stopped, so the lower
priority listeners on that event don't get called.
Now that the class is created, you just need to register it as a service and
notify Symfony that it is a "listener" on the ``kernel.exception`` event by
using a special "tag":

0 comments on commit f591e6e

Please sign in to comment.