Router extends Worker
A worker to choose which function to run depending to request
Table of Contents
- $next : Worker
- The next worker
- $routes : array<string|int, mixed>
- Array which contains a list of routes for routing
- __construct() : mixed
- getNext() : Worker
- Get the worker after this worker in the pipe
- run() : Entity
- Function which start the execution to a chain of workers by starting from this worker
- setNext() : void
- Set the worker after this worker in the pipe
- process() : Entity
- Function which contains instruction to execute when the worker run
- chooseRoute() : Route
- Choose a route
- getRouteParams() : null|array<string|int, mixed>
- Compare a path and an uri
Properties
$next
The next worker
private
Worker
$next
$routes
Array which contains a list of routes for routing
private
array<string|int, mixed>
$routes
Methods
__construct()
public
__construct(array<string|int, mixed> $routes) : mixed
Parameters
- $routes : array<string|int, mixed>
Return values
mixed —getNext()
Get the worker after this worker in the pipe
public
getNext() : Worker
Return values
Worker —run()
Function which start the execution to a chain of workers by starting from this worker
public
run(Entity $data[, bool $rewrite_data = false ]) : Entity
Parameters
- $data : Entity
- $rewrite_data : bool = false
Return values
Entity —setNext()
Set the worker after this worker in the pipe
public
setNext(Worker $next) : void
Parameters
- $next : Worker
Return values
void —process()
Function which contains instruction to execute when the worker run
protected
process(Entity $data) : Entity
Parameters
- $data : Entity
Return values
Entity —chooseRoute()
Choose a route
private
chooseRoute(Request $request) : Route
Parameters
- $request : Request
Return values
Route —getRouteParams()
Compare a path and an uri
private
getRouteParams(string $path, string $uri) : null|array<string|int, mixed>
Parameters
- $path : string
- $uri : string
Return values
null|array<string|int, mixed> —Array which contains eventual parameters when the path and the uri are same. null else