RouteDispatcher extends Dispatcher

Dispatcher which resolves a route to call a controller and method (but also a callable)

Table of Contents

Properties

$container  : ContainerInterface

Methods

__construct()  : mixed
dispatch()  : ResponseInterface
Main method checks the target of the route, and tries to call it.
addAndValidateModuleConfiguration()  : mixed
Adds configuration for a module and checks module permissions for the current user.
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.
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.
getFormProtection()  : AbstractFormProtection
Wrapper method for static form protection utility
getModuleConfiguration()  : array<string|int, mixed>
Returns the module configuration which is provided during module registration

Properties

$container

protected ContainerInterface $container

Methods

__construct()

public __construct(ContainerInterface $container, UriBuilder $uriBuilder) : mixed
Parameters
$container : ContainerInterface
$uriBuilder : UriBuilder

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
throws
InvalidRequestTokenException

if the route requested a token, but this token did not match

throws
MissingRequestTokenException

if the route requested a token, but there was none

throws
InvalidArgumentException

if the defined target for the route is invalid

Return values
ResponseInterface

the filled response by the callable / controller/action

addAndValidateModuleConfiguration()

Adds configuration for a module and checks module permissions for the current user.

protected addAndValidateModuleConfiguration(ServerRequestInterface $request, Route $route) : mixed
Parameters
$request : ServerRequestInterface
$route : Route
Tags
throws
RuntimeException

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
see
UriBuilder

where the token is generated.

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|null

getCallableFromTarget()

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.

Tags
throws
InvalidArgumentException
Return values
callable

getModuleConfiguration()

Returns the module configuration which is provided during module registration

protected getModuleConfiguration(string $moduleName) : array<string|int, mixed>
Parameters
$moduleName : string
Tags
throws
RuntimeException
Return values
array<string|int, mixed>

        
On this page

Search results