Skip to content

Removed deprecations for argument/controller resolvers #8636

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

Merged
merged 1 commit into from
Nov 13, 2017
Merged
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
19 changes: 2 additions & 17 deletions components/http_kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ and is one of the constructor arguments to ``HttpKernel``.
:align: center

Your job is to create a class that implements the interface and fill in its
two methods: ``getController()`` and ``getArguments()``. In fact, one default
implementation already exists, which you can use directly or learn from:
method: ``getController()``. In fact, one default implementation already
exists, which you can use directly or learn from:
:class:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver`.
This implementation is explained more in the sidebar below::

Expand All @@ -232,30 +232,15 @@ This implementation is explained more in the sidebar below::
interface ControllerResolverInterface
{
public function getController(Request $request);

public function getArguments(Request $request, $controller);
}

.. caution::

The ``getArguments()`` method in the
:class:`Symfony\\Component\\Httpkernel\\Controller\\ControllerResolver` and
respective interface
:class:`Symfony\\Component\\Httpkernel\\Controller\\ControllerResolverInterface`
are deprecated as of 3.1 and will be removed in 4.0. You can use the
:class:`Symfony\\Component\\Httpkernel\\Controller\\ArgumentResolver` which
uses the :class:`Symfony\\Component\\Httpkernel\\Controller\\ArgumentResolverInterface`
instead.

Internally, the ``HttpKernel::handle()`` method first calls
:method:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface::getController`
on the controller resolver. This method is passed the ``Request`` and is responsible
for somehow determining and returning a PHP callable (the controller) based
on the request's information.

The second method, :method:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface::getArguments`,
will be called after another event - ``kernel.controller`` - is dispatched.

.. sidebar:: Resolving the Controller in the Symfony Framework

The Symfony Framework uses the built-in
Expand Down
23 changes: 12 additions & 11 deletions create_framework/http_kernel_controller_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,9 @@ based on a Request object. All controller resolvers implement the following inte
// ...
interface ControllerResolverInterface
{
function getController(Request $request);

function getArguments(Request $request, $controller);
public function getController(Request $request);
}

.. caution::

The ``getArguments()`` method is deprecated as of Symfony 3.1. and will be
removed in 4.0. You can use the
:class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver` which
uses the :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface`
instead.

The ``getController()`` method relies on the same convention as the one we
have defined earlier: the ``_controller`` request attribute must contain the
Expand Down Expand Up @@ -98,7 +89,17 @@ resolver from HttpKernel::

Now, let's see how the controller arguments are guessed. ``getArguments()``
introspects the controller signature to determine which arguments to pass to
it by using the native PHP `reflection`_.
it by using the native PHP `reflection`_. This method is defined in the
following interface::

namespace Symfony\Component\HttpKernel\Controller;

// ...
interface ArgumentResolverInterface
{
public function getArguments(Request $request, $controller);
}


The ``indexAction()`` method needs the Request object as an argument.
``getArguments()`` knows when to inject it properly if it is type-hinted
Expand Down