From 25e1069ef7873b430718ffbd5fba1f49817ccdc0 Mon Sep 17 00:00:00 2001 From: Roger Llopart Pla Date: Sat, 29 Nov 2014 10:35:35 +0100 Subject: [PATCH 1/4] Added notes specifying the propagation behaviour for kernel.view and kernel.exception. --- components/http_kernel/introduction.rst | 10 ++++++++++ cookbook/service_container/event_listener.rst | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/components/http_kernel/introduction.rst b/components/http_kernel/introduction.rst index 3fee78f30b7..698a770f1ed 100644 --- a/components/http_kernel/introduction.rst +++ b/components/http_kernel/introduction.rst @@ -391,6 +391,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, so the lower priority listeners on that event don't get called. + .. sidebar:: ``kernel.view`` in the Symfony Framework There is no default listener inside the Symfony Framework for the ``kernel.view`` @@ -522,6 +527,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, so the lower priority listeners on that event don't get called. + .. sidebar:: ``kernel.exception`` in the Symfony Framework There are two main listeners to ``kernel.exception`` when using the diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index a78acded921..2fb529b64a6 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -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.view`` or ``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": From d13943a8029aab08ad943242b87c3fc6e17f04ad Mon Sep 17 00:00:00 2001 From: Roger Llopart Pla Date: Sat, 29 Nov 2014 14:02:00 +0100 Subject: [PATCH 2/4] Add missing info about kernel.request event. --- components/http_kernel/introduction.rst | 5 +++++ cookbook/service_container/event_listener.rst | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/http_kernel/introduction.rst b/components/http_kernel/introduction.rst index 698a770f1ed..dfed94ab88d 100644 --- a/components/http_kernel/introduction.rst +++ b/components/http_kernel/introduction.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.view`` event, the propagation + is stopped, so the lower priority listeners on that event don't get called. + .. sidebar:: ``kernel.request`` in the Symfony Framework The most important listener to ``kernel.request`` in the Symfony Framework diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index 2fb529b64a6..ecba442b697 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -59,9 +59,9 @@ event is just one of the core kernel events:: .. note:: - When setting a response for the ``kernel.view`` or ``kernel.exception`` - events, the propagation is stopped, so the lower priority listeners on - that event don't get called. + 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 From e72975037c1ce553150baff88e5a546c312bb203 Mon Sep 17 00:00:00 2001 From: Roger Llopart Pla Date: Sat, 29 Nov 2014 14:31:49 +0100 Subject: [PATCH 3/4] Changed phrasing to explain the effects off propagation stopping. --- components/http_kernel/introduction.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/http_kernel/introduction.rst b/components/http_kernel/introduction.rst index dfed94ab88d..6168d4ca196 100644 --- a/components/http_kernel/introduction.rst +++ b/components/http_kernel/introduction.rst @@ -170,7 +170,7 @@ attributes). .. note:: When setting a response for the ``kernel.view`` event, the propagation - is stopped, so the lower priority listeners on that event don't get called. + is stopped. This means listeners with lower priority won't be executed. .. sidebar:: ``kernel.request`` in the Symfony Framework @@ -399,7 +399,7 @@ return a ``Response``. .. note:: When setting a response for the ``kernel.view`` event, the propagation - is stopped, so the lower priority listeners on that event don't get called. + is stopped. This means listeners with lower priority won't be executed. .. sidebar:: ``kernel.view`` in the Symfony Framework @@ -535,7 +535,7 @@ below for more details). .. note:: When setting a response for the ``kernel.exception`` event, the propagation - is stopped, so the lower priority listeners on that event don't get called. + is stopped. This means listeners with lower priority won't be executed. .. sidebar:: ``kernel.exception`` in the Symfony Framework From bebce0e0f9f7969e4b9cd7688737d142a132021c Mon Sep 17 00:00:00 2001 From: Roger Llopart Pla Date: Sun, 30 Nov 2014 11:17:47 +0100 Subject: [PATCH 4/4] Fix incorrect event name. --- components/http_kernel/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/http_kernel/introduction.rst b/components/http_kernel/introduction.rst index 6168d4ca196..a260aa5a9ad 100644 --- a/components/http_kernel/introduction.rst +++ b/components/http_kernel/introduction.rst @@ -169,7 +169,7 @@ attributes). .. note:: - When setting a response for the ``kernel.view`` event, the propagation + 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