From cd820d798a673d23d7d671bdea4a613591e5efe4 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 23 May 2015 11:51:25 -0400 Subject: [PATCH 1/3] Proofreading after #4901 --- cookbook/profiler/profiling_data.rst | 2 +- reference/dic_tags.rst | 3 ++ reference/events.rst | 42 +++++++++++++--------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/cookbook/profiler/profiling_data.rst b/cookbook/profiler/profiling_data.rst index fd5937f51e3..761dae943e6 100644 --- a/cookbook/profiler/profiling_data.rst +++ b/cookbook/profiler/profiling_data.rst @@ -20,7 +20,7 @@ this token is available in the ``X-Debug-Token`` HTTP header of the response. Using this token, you can access the profile of any past response thanks to the :method:`Symfony\\Component\\HttpKernel\\Profiler\\Profiler::loadProfile` method:: - $token = $request->headers->get('X-Debug-Token'); + $token = $response->headers->get('X-Debug-Token'); $profile = $container->get('profiler')->loadProfile($token); .. tip:: diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 993d7ad80e0..47e8c43aebf 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -549,6 +549,9 @@ cookbook entry. For another practical example of a kernel listener, see the cookbook article: :doc:`/cookbook/request/mime_type`. +Core Event Listener Reference +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + For the reference of Event Listeners associated with each kernel event, see the :doc:`Symfony Events Reference `. diff --git a/reference/events.rst b/reference/events.rst index f60c566380a..996ac216dae 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -1,6 +1,11 @@ Symfony Framework Events ======================== +When the Symfony Framework (or anything using the :class:`Symfony\\Component\\HttpKernel\\HttpKernel`) +handles a request, a few core events are dispatched so that you can add listeners +throughout the process. These are called the "kernel events". For a larger +explanation, see :doc:`/reference/http_kernel/introduction`. + Kernel Events ------------- @@ -20,22 +25,13 @@ each event has access to the following information: .. _kernel-core-request: -``kernel.request`` -~~~~~~~~~~~~~~~~~~ +kernel.request +~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent` -The goal of this event is to either return a ``Response`` object immediately -or setup variables so that a Controller can be called after the event. Any -listener can return a ``Response`` object via the ``setResponse()`` method on -the event. In this case, all other listeners won't be called. - -This event is used by the FrameworkBundle to populate the ``_controller`` -``Request`` attribute, via the -:class:`Symfony\\Bundle\\FrameworkBundle\\EventListener\\RouterListener`. -RequestListener uses a :class:`Symfony\\Component\\Routing\\RouterInterface` -object to match the ``Request`` and determine the Controller name (stored in the -``_controller`` ``Request`` attribute). +This event is dispatched very early in Symfony, before the controller is +determined. .. seealso:: @@ -54,7 +50,7 @@ Listener Class Name P :class:`Symfony\\Component\\Security\\Http\\Firewall` 8 ============================================================================= ======== -``kernel.controller`` +kernel.controller ~~~~~~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent` @@ -84,8 +80,8 @@ Listener Class Name :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\RequestDataCollector` 0 ============================================================================== ======== -``kernel.view`` -~~~~~~~~~~~~~~~ +kernel.view +~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent` @@ -114,8 +110,8 @@ method:: Read more on the :ref:`kernel.view event `. -``kernel.response`` -~~~~~~~~~~~~~~~~~~~ +kernel.response +~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent` @@ -162,8 +158,8 @@ Listener Class Name :class:`Symfony\\Component\\HttpKernel\\EventListener\\StreamedResponseListener` -1024 =================================================================================== ======== -``kernel.terminate`` -~~~~~~~~~~~~~~~~~~~~ +kernel.terminate +~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\PostResponseEvent` @@ -185,8 +181,8 @@ Listener Class Name Prior .. _kernel-kernel.exception: -``kernel.exception`` -~~~~~~~~~~~~~~~~~~~~ +kernel.exception +~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent` @@ -219,7 +215,7 @@ and set a new ``Exception`` object, or do nothing:: response won't work. If you want to overwrite the status code (which you should not without a good reason), set the ``X-Status-Code`` header:: - return new Response( + $response = Response( 'Error', 404 // ignored, array('X-Status-Code' => 200) From 106bda9e7967a3da9afa1582d408a200cb731a70 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 23 May 2015 12:14:15 -0400 Subject: [PATCH 2/3] re-adding literals --- reference/events.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/reference/events.rst b/reference/events.rst index 996ac216dae..b2268c31876 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -25,8 +25,8 @@ each event has access to the following information: .. _kernel-core-request: -kernel.request -~~~~~~~~~~~~~~ +``kernel.request`` +~~~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent` @@ -50,7 +50,7 @@ Listener Class Name P :class:`Symfony\\Component\\Security\\Http\\Firewall` 8 ============================================================================= ======== -kernel.controller +``kernel.controller`` ~~~~~~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent` @@ -80,8 +80,8 @@ Listener Class Name :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\RequestDataCollector` 0 ============================================================================== ======== -kernel.view -~~~~~~~~~~~ +``kernel.view`` +~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent` @@ -110,8 +110,8 @@ method:: Read more on the :ref:`kernel.view event `. -kernel.response -~~~~~~~~~~~~~~~ +``kernel.response`` +~~~~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent` @@ -158,8 +158,8 @@ Listener Class Name :class:`Symfony\\Component\\HttpKernel\\EventListener\\StreamedResponseListener` -1024 =================================================================================== ======== -kernel.terminate -~~~~~~~~~~~~~~~~ +``kernel.terminate`` +~~~~~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\PostResponseEvent` @@ -181,8 +181,8 @@ Listener Class Name Prior .. _kernel-kernel.exception: -kernel.exception -~~~~~~~~~~~~~~~~ +``kernel.exception`` +~~~~~~~~~~~~~~~~~~~~ **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent` From c7326daa879d96f3b3fa23724ac97e04229a0090 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 23 May 2015 12:20:38 -0400 Subject: [PATCH 3/3] another fix! --- reference/events.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/events.rst b/reference/events.rst index b2268c31876..60740ac9fe0 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -4,7 +4,7 @@ Symfony Framework Events When the Symfony Framework (or anything using the :class:`Symfony\\Component\\HttpKernel\\HttpKernel`) handles a request, a few core events are dispatched so that you can add listeners throughout the process. These are called the "kernel events". For a larger -explanation, see :doc:`/reference/http_kernel/introduction`. +explanation, see :doc:`/components/http_kernel/introduction`. Kernel Events -------------