RouterActionRequestHandler
in package
implements
RequestHandlerInterface
The router action handler allows the application to map a route to an action within a controller. This generates a request handler that will use the route to extract parameters and appropriately invoke the action.
For example, when building a route, the application is unable to determine how the route's parameters will be resolved. The route /user/{id} will be mapped to the UserController::retrieve action that receives the id as a parameter.
This means that for a request to /user/1 the route is created without knowledge of the requested url, but the router must return a request handler capable of handling the URL /user/1
This leaves two options, returning a request handler that is able to reuse the route to retrieve the parameters it needs, or creating a single use request handler that ignores the request it receives. We're choosing the first approach for this.
Interfaces, Classes and Traits
- RequestHandlerInterface
Table of Contents
- $action : mixed
- $controller : mixed
- $route : URIPattern
- __construct() : mixed
- handle() : ResponseInterface
Properties
$action
private
mixed
$action
$controller
private
mixed
$controller
$route
private
URIPattern
$route
Methods
__construct()
public
__construct(URIPattern $route, string $controller, string $action) : mixed
Parameters
- $route : URIPattern
- $controller : string
- $action : string
Return values
mixed —handle()
public
handle(ServerRequestInterface $request) : ResponseInterface
Parameters
- $request : ServerRequestInterface