On this page
Class ControllerFactory
Factory method for building controllers for request.
Property Summary
-
$container protected
Cake\Core\ContainerInterface
-
$controller protected
Cake\Controller\Controller
Method Summary
__construct() public
Constructor
coerceStringToType() protected
Coerces string argument to primitive type.
create() public
Create a controller for a given request.
getActionArgs() protected
Get the arguments for the controller action invocation.
getControllerClass() public
Determine the controller class name based on current request and controller param
handle() public
Invoke the action.
invoke() public
Invoke a controller's action and wrapping methods.
missingController() protected
Throws an exception when a controller is missing.
Method Detail
__construct() public
__construct(Cake\Core\ContainerInterface $container)
Constructor
Parameters
Cake\Core\ContainerInterface
$container-
The container to build controllers with.
coerceStringToType() protected
coerceStringToType(string $argument, ReflectionNamedType $type): array|string|float|int|bool|null
Coerces string argument to primitive type.
Parameters
string
$argument-
Argument to coerce
ReflectionNamedType
$type-
Parameter type
Returns
array|string|float|int|bool|null
create() public
create(Psr\Http\Message\ServerRequestInterface $request): Cake\Controller\Controller
Create a controller for a given request.
Parameters
Psr\Http\Message\ServerRequestInterface
$request-
The request to build a controller for.
Returns
Cake\Controller\Controller
Throws
Cake\Http\Exception\MissingControllerException
getActionArgs() protected
getActionArgs(Closure $action, array $passedParams): array
Get the arguments for the controller action invocation.
Parameters
Closure
$action-
Controller action.
array
$passedParams-
Params passed by the router.
Returns
array
getControllerClass() public
getControllerClass(Cake\Http\ServerRequest $request): string|null
Determine the controller class name based on current request and controller param
Parameters
Cake\Http\ServerRequest
$request-
The request to build a controller for.
Returns
string|null
handle() public
handle(ServerRequestInterface $request): Psr\Http\Message\ResponseInterface
Invoke the action.
May call other collaborating code to generate the response.
Parameters
ServerRequestInterface
$request-
Request instance.
Returns
Psr\Http\Message\ResponseInterface
invoke() public
invoke(mixed $controller): Psr\Http\Message\ResponseInterface
Invoke a controller's action and wrapping methods.
Parameters
mixed
$controller-
The controller to invoke.
Returns
Psr\Http\Message\ResponseInterface
Throws
Cake\Controller\Exception\MissingActionException
If controller action is not found.
UnexpectedValueException
If return value of action method is not null or ResponseInterface instance.
missingController() protected
missingController(Cake\Http\ServerRequest $request): Cake\Http\Exception\MissingControllerException
Throws an exception when a controller is missing.
Parameters
Cake\Http\ServerRequest
$request-
The request.
Returns
Cake\Http\Exception\MissingControllerException
Property Detail
$container protected
Type
Cake\Core\ContainerInterface
$controller protected
Type
Cake\Controller\Controller
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Controller.ControllerFactory.html