RouteDispatcher extends Dispatcher
Dispatcher which resolves a route to call a controller and method (but also a callable)
Table of Contents
Properties
- $container : ContainerInterface
- $factory : AccessFactory
- $formProtectionFactory : FormProtectionFactory
- $storage : AccessStorage
Methods
- __construct() : mixed
- dispatch() : ResponseInterface
- Main method checks the target of the route, and tries to call it.
- assertRequestToken() : void
- Checks if the request token is valid. This is checked to see if the route is really created by the same instance. Should be called for all routes in the backend except for the ones that don't require a login.
- assertSudoMode() : void
- Asserts that sudo mode verification was processed for this route before and that it did not expire, yet. In case (re-)verification is required, a corresponding `AccessClaim` is persisted in the user session storage, and the process of showing the verification dialogs is initiated.
- enforceReferrer() : ResponseInterface|null
- Evaluates HTTP `Referer` header (which is denied by client to be a custom value) - attempts to ensure the value is given using a HTML client refresh.
- getCallableFromTarget() : callable
- Creates a callable out of the given parameter, which can be a string, a callable / closure or an array which can be invoked as a function.
Properties
$container
protected
ContainerInterface
$container
$factory read-only
protected
AccessFactory
$factory
$formProtectionFactory read-only
protected
FormProtectionFactory
$formProtectionFactory
$storage read-only
protected
AccessStorage
$storage
Methods
__construct()
public
__construct(FormProtectionFactory $formProtectionFactory, AccessFactory $factory, AccessStorage $storage, ContainerInterface $container) : mixed
Parameters
- $formProtectionFactory : FormProtectionFactory
- $factory : AccessFactory
- $storage : AccessStorage
- $container : ContainerInterface
dispatch()
Main method checks the target of the route, and tries to call it.
public
dispatch(ServerRequestInterface $request) : ResponseInterface
Parameters
- $request : ServerRequestInterface
-
the current server request
Tags
Return values
ResponseInterface —the filled response by the callable / controller/action
assertRequestToken()
Checks if the request token is valid. This is checked to see if the route is really created by the same instance. Should be called for all routes in the backend except for the ones that don't require a login.
protected
assertRequestToken(ServerRequestInterface $request, Route $route) : void
Parameters
- $request : ServerRequestInterface
- $route : Route
Tags
assertSudoMode()
Asserts that sudo mode verification was processed for this route before and that it did not expire, yet. In case (re-)verification is required, a corresponding `AccessClaim` is persisted in the user session storage, and the process of showing the verification dialogs is initiated.
protected
assertSudoMode(ServerRequestInterface $request) : void
Parameters
- $request : ServerRequestInterface
enforceReferrer()
Evaluates HTTP `Referer` header (which is denied by client to be a custom value) - attempts to ensure the value is given using a HTML client refresh.
protected
enforceReferrer(ServerRequestInterface $request, Route $route) : ResponseInterface|null
see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer
Parameters
- $request : ServerRequestInterface
- $route : Route
Return values
ResponseInterface|nullgetCallableFromTarget()
Creates a callable out of the given parameter, which can be a string, a callable / closure or an array which can be invoked as a function.
protected
getCallableFromTarget(array<string|int, mixed>|string|callable $target) : callable
Parameters
- $target : array<string|int, mixed>|string|callable
-
the target which is being resolved.