diff --git a/components/http_kernel/introduction.rst b/components/http_kernel/introduction.rst index 2e2ae670da0..cbbcbb377c9 100644 --- a/components/http_kernel/introduction.rst +++ b/components/http_kernel/introduction.rst @@ -306,6 +306,8 @@ on the event object that's passed to listeners on this event. those to objects, which are then stored in the ``attributes`` property of the ``Request`` object. Read the next section to see why this is important. +.. _component-http-kernel-kernel-controller-arguments: + 4) Getting the Controller Arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -341,6 +343,13 @@ of arguments that should be passed when executing that callable. :class:`Symfony\\Component\\HttpFoundation\\Request` object, then the ``Request`` is passed in as the value. +.. versionadded:: 3.1 + The ``kernel.controller_arguments`` event was introduced in Symfony 3.1. + +Once controller arguments have been resolved by Symfony, the +``kernel.controller_arguments`` event is triggered. This allows to modify or +replace the arguments and the controller to fit your application needs. + .. _component-http-kernel-calling-controller: 5) Calling the Controller diff --git a/reference/events.rst b/reference/events.rst index 800c47039d1..72e552913b0 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -80,6 +80,33 @@ Listener Class Name :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\RequestDataCollector` 0 ============================================================================== ======== +``kernel.controller_arguments`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 3.1 + The ``kernel.controller_arguments`` event was introduced in Symfony 3.1. + +**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerArgumentsEvent` + +This event allows to modify the arguments of the controller once they have been +resolved by Symfony:: + + use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent; + + public function onKernelControllerArguments(FilterControllerArgumentsEvent $event) + { + $controller = $event->getController(); + $arguments = $event->getArguments(); + // ... + + // the arguments can be changed as needed + $event->setArguments(array('foo', 'bar')); + } + +.. seealso:: + + Read more on the :ref:`kernel.controller_arguments event `. + ``kernel.view`` ~~~~~~~~~~~~~~~