8000 Merge branch '3.4' into 4.2 · symfony/symfony-docs@5543a18 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5543a18

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: Added the kernel.controller_arguments description Http kernel controller arguments
2 parents 0d6c702 + bcfa1e4 commit 5543a18

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed

README.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ This documentation is rendered online at https://symfony.com/doc/current/
66
Contributing
77
------------
88

9-
>**Note**
10-
>Unless you're documenting a feature that was introduced *after* Symfony 3.4
11-
>(e.g. in Symfony 4.2), all pull requests must be based off of the **3.4** branch,
12-
>**not** the master or older branches.
9+
> **Note**
10+
> Unless you're documenting a feature that was introduced *after* Symfony 3.4
11+
> (e.g. in Symfony 4.2), all pull requests must be based off of the **3.4** branch,
12+
> **not** the master or older branches.
1313
1414
We love contributors! For more information on how you can contribute to the
1515
Symfony documentation, please read

components/http_kernel.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -604,17 +604,18 @@ each event has their own event object:
604604

605605
.. _component-http-kernel-event-table:
606606

607-
===================== ================================ ===================================================================================
608-
Name ``KernelEvents`` Constant Argument passed to the listener
609-
===================== ================================ ===================================================================================
610-
kernel.request ``KernelEvents::REQUEST`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent`
611-
kernel.controller ``KernelEvents::CONTROLLER`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent`
612-
kernel.view ``KernelEvents::VIEW`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent`
613-
kernel.response ``KernelEvents::RESPONSE`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent`
614-
kernel.finish_request ``KernelEvents::FINISH_REQUEST`` :class:`Symfony\\Component\\HttpKernel\\Event\\FinishRequestEvent`
615-
kernel.terminate ``KernelEvents::TERMINATE`` :class:`Symfony\\Component\\HttpKernel\\Event\\PostResponseEvent`
616-
kernel.exception ``KernelEvents::EXCEPTION`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`
617-
===================== ================================ ===================================================================================
607+
=========================== ====================================== ===================================================================================
608+
Name ``KernelEvents`` Constant Argument passed to the listener
609+
=========================== ====================================== ===================================================================================
610+
kernel.request ``KernelEvents::REQUEST`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent`
611+
kernel.controller ``KernelEvents::CONTROLLER`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent`
612+
kernel.controller_arguments ``KernelEvents::CONTROLLER_ARGUMENTS`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerArgumentsEvent`
613+
kernel.view ``KernelEvents::VIEW`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent`
614+
kernel.response ``KernelEvents::RESPONSE`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent`
615+
kernel.finish_request ``KernelEvents::FINISH_REQUEST`` :class:`Symfony\\Component\\HttpKernel\\Event\\FinishRequestEvent`
616+
kernel.terminate ``KernelEvents::TERMINATE`` :class:`Symfony\\Component\\HttpKernel\\Event\\PostResponseEvent`
617+
kernel.exception ``KernelEvents::EXCEPTION`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`
618+
=========================== ====================================== ===================================================================================
618619

619620
.. _http-kernel-working-example:
620621

reference/events.rst

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ their priorities:
7676
7777
$ php bin/console debug:event-dispatcher kernel.controller
7878
79+
``kernel.controller_arguments``
80+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81+
82+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerArgumentsEvent`
83+
84+
This event is dispatched just before a controller is called. It's useful to
85+
configure the arguments that are going to be passed to the controller.
86+
Typically, this is used to map URL routing parameters to their corresponding
87+
named arguments; or pass the current request when the ``Request`` type-hint is
88+
found::
89+
90+
public function onKernelControllerArguments(FilterControllerArgumentsEvent $event)
91+
{
92+
// ...
93+
94+
// get controller and request arguments
95+
$namedArguments = $event->getRequest()->attributes->all();
96+
$controllerArguments = $event->getArguments();
97+
98+
// set the controller arguments to modify the original arguments or add new ones
99+
$event->setArguments($newArguments);
100+
}
101+
102+
Execute this command to find out which listeners are registered for this event and
103+
their priorities:
104+
105+
.. code-block:: terminal
106+
107+
$ php bin/console debug:event-dispatcher kernel.controller_arguments
108+
79109
``kernel.view``
80110
~~~~~~~~~~~~~~~
81111

@@ -142,10 +172,9 @@ their priorities:
142172

143173
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FinishRequestEvent`
144174

145-
This event is dispatched after a :ref:`sub request <http-kernel-sub-requests>`
146-
has finished. It's useful to reset the global state of the application (for
147-
example, the translator listener resets the translator's locale to the one of
148-
the parent request)::
175+
This event is dispatched after the ``kernel.response`` event. It's useful to reset
176+
the global state of the application (for example, the translator listener resets
177+
the translator's locale to the one of the parent request)::
149178

150179
public function onKernelFinishRequest(FinishRequestEvent $event)
151180
{

0 commit comments

Comments
 (0)
0