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
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
$logger
private
mixed
$logger
$supportsScalarTypes
If scalar types exists.
private
bool
$supportsScalarTypes
$supportsVariadic
If the ...$arg functionality is available.
private
bool
$supportsVariadic
Requires at least PHP 5.6.0 or HHVM 3.9.1
Methods
__construct()
public
__construct([LoggerInterface $logger = null ]) : mixed
Parameters
- $logger : LoggerInterface = null
Return values
mixed —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
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
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
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