@@ -289,26 +289,31 @@ After the controller callable has been determined, ``HttpKernel::handle()``
289289dispatches the ``kernel.controller `` event. Listeners to this event might initialize
290290some part of the system that needs to be initialized after certain things
291291have been determined (e.g. the controller, routing information) but before
292- the controller is executed. For some examples, see the Symfony section below.
292+ the controller is executed.
293+
294+ Another typical use-case for this event is to retrieve the attributes from
295+ the controller using the :method: `Symfony\\ Component\\ HttpKernel\\ Event\\ ControllerEvent::getAttributes `
296+ method. See the Symfony section below for some examples.
297+
298+ .. versionadded :: 6.2
299+
300+ The ``ControllerEvent::getAttributes() `` method was introduced in Symfony 6.2.
293301
294302Listeners to this event can also change the controller callable completely
295303by calling :method: `ControllerEvent::setController <Symfony\\ Component\\ HttpKernel\\ Event\\ ControllerEvent::setController> `
296304on the event object that's passed to listeners on this event.
297305
298306.. sidebar :: ``kernel.controller`` in the Symfony Framework
299307
300- There are a few minor listeners to the ``kernel.controller `` event in
301- the Symfony Framework, and many deal with collecting profiler data when
302- the profiler is enabled.
308+ An interesting listener to ``kernel.controller `` in the Symfony
309+ Framework is :class: `Symfony\\ Component\\ HttpKernel\\ EventListener\\ CacheAttributeListener `.
310+ This class fetches ``#[Cache] `` attribute configuration from the
311+ controller and uses it to configure :doc: `HTTP caching </http_cache >`
312+ on the response.
303313
304- One interesting listener comes from the `SensioFrameworkExtraBundle `_. This
305- listener's `#[ParamConverter] `_ functionality allows you to pass a full object
306- (e.g. a ``Post `` object) to your controller instead of a scalar value (e.g.
307- an ``id `` parameter that was on your route). The listener -
308- ``ParamConverterListener `` - uses reflection to look at each of the
309- arguments of the controller and tries to use different methods to convert
310- those to objects, which are then stored in the ``attributes `` property of
311- the ``Request `` object. Read the next section to see why this is important.
314+ There are a few other minor listeners to the ``kernel.controller `` event in
315+ the Symfony Framework that deal with collecting profiler data when the
316+ profiler is enabled.
312317
3133184) Getting the Controller Arguments
314319~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -749,6 +754,4 @@ Learn more
749754.. _reflection : https://www.php.net/manual/en/book.reflection.php
750755.. _FOSRestBundle : https://github.com/friendsofsymfony/FOSRestBundle
751756.. _`PHP FPM` : https://www.php.net/manual/en/install.fpm.php
752- .. _`SensioFrameworkExtraBundle` : https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html
753- .. _`#[ParamConverter]` : https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
754757.. _variadic : https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list
0 commit comments