StaticRouteResolver implements MiddlewareInterface
Resolves static routes - can return configured content directly or load content from file / urls
Table of Contents
Interfaces
- MiddlewareInterface
Properties
Methods
- __construct() : mixed
- process() : ResponseInterface
- Checks if there is a valid site with route configuration.
- getApplicableStaticRoute() : array<string|int, mixed>|null
- Find the proper configuration for the static route in the static route configuration. Mainly: - needs to have a valid "route" property - needs to have a "type"
- getFromFile() : array<string|int, mixed>
- getFromUri() : array<string|int, mixed>
- getPageUri() : string
- resolveByType() : array<string|int, mixed>
Properties
$linkService
protected
LinkService
$linkService
$requestFactory
protected
RequestFactory
$requestFactory
Methods
__construct()
public
__construct(RequestFactory $requestFactory, LinkService $linkService) : mixed
Parameters
- $requestFactory : RequestFactory
- $linkService : LinkService
process()
Checks if there is a valid site with route configuration.
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface
Return values
ResponseInterfacegetApplicableStaticRoute()
Find the proper configuration for the static route in the static route configuration. Mainly: - needs to have a valid "route" property - needs to have a "type"
protected
getApplicableStaticRoute(array<string|int, mixed> $staticRouteConfiguration, Site $site, string $uriPath) : array<string|int, mixed>|null
Parameters
- $staticRouteConfiguration : array<string|int, mixed>
-
the "routes" part of the site configuration
- $site : Site
-
the current site where the configuration is based on
- $uriPath : string
-
the path of the current request - used to match the "route" value of a single static route
Return values
array<string|int, mixed>|null —the configuration for the static route that matches, or null if no route is given
getFromFile()
protected
getFromFile(File $file) : array<string|int, mixed>
Parameters
- $file : File
Return values
array<string|int, mixed>getFromUri()
protected
getFromUri(string $uri) : array<string|int, mixed>
Parameters
- $uri : string
Return values
array<string|int, mixed>getPageUri()
protected
getPageUri(ServerRequestInterface $request, Site $site, array<string|int, mixed> $urlParams) : string
Parameters
- $request : ServerRequestInterface
- $site : Site
- $urlParams : array<string|int, mixed>
Tags
Return values
stringresolveByType()
protected
resolveByType(ServerRequestInterface $request, Site $site, string $type, array<string|int, mixed> $routeConfig) : array<string|int, mixed>
Parameters
- $request : ServerRequestInterface
- $site : Site
- $type : string
- $routeConfig : array<string|int, mixed>