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

Methods

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

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.

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

        
On this page

Search results