From 474b3d5bc290a9a50cb52adb57aaf2ef60977254 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 5 Apr 2016 15:34:26 +0200 Subject: [PATCH 1/3] Documented the new kernel.controller_arguments event --- components/http_kernel/introduction.rst | 9 +++++++++ reference/events.rst | 27 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/components/http_kernel/introduction.rst b/components/http_kernel/introduction.rst index 2e2ae670da0..cf6a9d704c5 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 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..8449e64fc4d 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 can be an entry point used 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`` ~~~~~~~~~~~~~~~ From 03c9a52981e6b0fede35a0848f38938af500b868 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 3 May 2016 10:29:27 +0200 Subject: [PATCH 2/3] Reworded and improved --- 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 cf6a9d704c5..cbbcbb377c9 100644 --- a/components/http_kernel/introduction.rst +++ b/components/http_kernel/introduction.rst @@ -346,9 +346,9 @@ of arguments that should be passed when executing that callable. .. 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 to fit your -application needs. +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: From 4db0adbc8fd1976536963894b2291061899fd686 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 21 May 2016 11:28:06 +0200 Subject: [PATCH 3/3] Minor fixes --- reference/events.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/events.rst b/reference/events.rst index 8449e64fc4d..72e552913b0 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -88,8 +88,8 @@ Listener Class Name **Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerArgumentsEvent` -This event can be an entry point used to modify the arguments of the controller -once they have been resolved by Symfony:: +This event allows to modify the arguments of the controller once they have been +resolved by Symfony:: use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;