RedirectHandler implements MiddlewareInterface
Hooks into the frontend request, and checks if a redirect should apply, If so, a redirect response is triggered.
Table of Contents
Interfaces
- MiddlewareInterface
Properties
- $eventDispatcher : EventDispatcherInterface
- $logger : LoggerInterface
- $redirectService : RedirectService
- $responseFactory : ResponseFactoryInterface
Methods
- __construct() : mixed
- process() : ResponseInterface
- buildRedirectResponse() : ResponseInterface
- redirectUriWillRedirectToCurrentUri() : bool
- Checks if redirect uri matches current request uri.
- sanitizeUriForComparison() : UriInterface
- Strip down uri to be suitable to make valid comparison in 'redirectUriWillRedirectToCurrentUri()' if uri is pointing to itself and redirect should be processed.
Properties
$eventDispatcher
protected
EventDispatcherInterface
$eventDispatcher
$logger
protected
LoggerInterface
$logger
$redirectService
protected
RedirectService
$redirectService
$responseFactory
protected
ResponseFactoryInterface
$responseFactory
Methods
__construct()
public
__construct(RedirectService $redirectService, EventDispatcherInterface $eventDispatcher, ResponseFactoryInterface $responseFactory, LoggerInterface $logger) : mixed
Parameters
- $redirectService : RedirectService
- $eventDispatcher : EventDispatcherInterface
- $responseFactory : ResponseFactoryInterface
- $logger : LoggerInterface
process()
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface
Return values
ResponseInterfacebuildRedirectResponse()
protected
buildRedirectResponse(UriInterface $uri, array<string|int, mixed> $redirectRecord) : ResponseInterface
Parameters
- $uri : UriInterface
- $redirectRecord : array<string|int, mixed>
Return values
ResponseInterfaceredirectUriWillRedirectToCurrentUri()
Checks if redirect uri matches current request uri.
protected
redirectUriWillRedirectToCurrentUri(ServerRequestInterface $request, UriInterface $redirectUri) : bool
Parameters
- $request : ServerRequestInterface
- $redirectUri : UriInterface
Return values
boolsanitizeUriForComparison()
Strip down uri to be suitable to make valid comparison in 'redirectUriWillRedirectToCurrentUri()' if uri is pointing to itself and redirect should be processed.
protected
sanitizeUriForComparison(UriInterface $uri, bool $relativeCheck) : UriInterface
Parameters
- $uri : UriInterface
- $relativeCheck : bool