Documentation

ControllerResolver
in package
implements ArgumentResolverInterface, ControllerResolverInterface

This implementation uses the '_controller' request attribute to determine the controller to execute and uses the request attributes to determine the controller method arguments.

Tags
author

Fabien Potencier fabien@symfony.com

Interfaces, Classes and Traits

ArgumentResolverInterface
An ArgumentResolverInterface instance knows how to determine the arguments for a specific action.
ControllerResolverInterface
A ControllerResolverInterface implementation knows how to determine the controller to execute based on a Request object.

Table of Contents

$logger  : mixed
$supportsScalarTypes  : bool
If scalar types exists.
$supportsVariadic  : bool
If the ...$arg functionality is available.
__construct()  : mixed
getArguments()  : array<string|int, mixed>
Returns the arguments to pass to the controller.
getController()  : callable|false
Returns the Controller instance associated with a Request.
createController()  : callable
Returns a callable for the given controller.
doGetArguments()  : array<string|int, mixed>
instantiateController()  : object
Returns an instantiated controller.
getControllerError()  : mixed
typeMatchesRequestClass()  : bool

Properties

$supportsVariadic

If the ...$arg functionality is available.

private bool $supportsVariadic

Requires at least PHP 5.6.0 or HHVM 3.9.1

Methods

getArguments()

Returns the arguments to pass to the controller.

public getArguments(Request $request, mixed $controller) : array<string|int, mixed>
Parameters
$request : Request
$controller : mixed
Tags
deprecated

This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.

Return values
array<string|int, mixed>

An array of arguments to pass to the controller

getController()

Returns the Controller instance associated with a Request.

public getController(Request $request) : callable|false

This method looks for a '_controller' request attribute that represents the controller name (a string like ClassName::MethodName).

Parameters
$request : Request
Return values
callable|false

A PHP callable representing the Controller, or false if this resolver is not able to determine the controller

createController()

Returns a callable for the given controller.

protected createController(string $controller) : callable
Parameters
$controller : string

A Controller string

Tags
throws
InvalidArgumentException

When the controller cannot be created

Return values
callable

A PHP callable

doGetArguments()

protected doGetArguments(Request $request, callable $controller, array<string|int, ReflectionParameter$parameters) : array<string|int, mixed>
Parameters
$request : Request
$controller : callable
$parameters : array<string|int, ReflectionParameter>
Tags
deprecated

This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.

Return values
array<string|int, mixed>

The arguments to use when calling the action

instantiateController()

Returns an instantiated controller.

protected instantiateController(string $class) : object
Parameters
$class : string

A class name

Return values
object

getControllerError()

private getControllerError(mixed $callable) : mixed
Parameters
$callable : mixed
Return values
mixed

typeMatchesRequestClass()

private typeMatchesRequestClass(ReflectionParameter $param, Request $request) : bool
Parameters
$param : ReflectionParameter
$request : Request
Return values
bool

Search results