Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Documented the new kernel.controller_arguments event #6434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions components/http_kernel/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions reference/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace is missing, otherwise its not very clear where to put this method IMO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can put it where you want (as long as you tell Symfony that this method is a listener for this event) .

And the current proposal is consistent with other snippets in the page

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 <component-http-kernel-kernel-controller-arguments>`.

``kernel.view``
~~~~~~~~~~~~~~~

Expand Down