PageRouter implements RouterInterface

Page Router - responsible for a page based on a request, by looking up the slug of the page path.

Is also used for generating URLs for pages.

Resolving is done via the "Route Candidate" pattern.

Example:

  • /about-us/team/management/

will look for all pages that have

  • /about-us
  • /about-us/
  • /about-us/team
  • /about-us/team/
  • /about-us/team/management
  • /about-us/team/management/

And create route candidates for that.

Please note: PageRouter does not restrict the HTTP method or is bound to any domain constraints, as the SiteMatcher has done that already.

The concept of the PageRouter is to resolve, and to generate URIs. On top, it is a facade to hide the dependency to symfony and to not expose its logic.

Table of Contents

Interfaces

RouterInterface
Base Router to be used all over the TYPO3 Core. Its base lies around PSR-7 requests + URIs, and special "RouteResult" objects.

Properties

$aspectFactory  : AspectFactory
$cacheHashCalculator  : CacheHashCalculator
$context  : Context
$enhancerFactory  : EnhancerFactory
$requestContextFactory  : RequestContextFactory
$site  : Site

Methods

__construct()  : mixed
A page router is always bound to a specific site.
generateUri()  : UriInterface
API for generating a page uri where the $route parameter is typically an array (a page record) or the page ID
matchRequest()  : RouteResultInterface|PageArguments
Finds a RouteResult based on the given request.
assertMaximumStaticMappableAmount()  : mixed
Asserts that possible amount of items in all static and countable mappers (such as StaticRangeMapper) is limited to 10000 in order to avoid brute-force scenarios and the risk of cache-flooding.
buildPageArguments()  : PageArguments
Builds route arguments. The important part here is to distinguish between static and dynamic arguments. Per default all arguments are dynamic until aspects can be used to really consider them as static (= 1:1 mapping between route value and resulting arguments).
filterProcessedParameters()  : array<string|int, mixed>
Determine parameters that have been processed.
generateCacheHash()  : string
getCacheHashParameters()  : array<string|int, mixed>
getEnhancersForPage()  : array<string|int, EnhancerInterface>
Fetch possible enhancers + aspects based on the current page configuration and the site configuration put into "routeEnhancers"
getSlugCandidateProvider()  : PageSlugCandidateProvider
isRouteReallyValidForLanguage()  : bool
Request may have been made with default page slug, also we are dealing with a site language variant. To avoid duplicate content, we need to revalidate that the eventually matched language route is really the available page language variant for the current lange. We do this at this late point to minimize the needed database queries instead of checking it for all build page candidates.
resolveMountPointParameterIntoPageSlug()  : string
When a MP parameter is given, the mount point parameter is resolved, and the slug of the new page is added while the same parts of the original pagePath is removed (before).
resolveType()  : string
Retrieves type from processed route and modifies remaining query parameters.

Properties

Methods

__construct()

A page router is always bound to a specific site.

public __construct(Site $site[, Context|null $context = null ]) : mixed
Parameters
$site : Site
$context : Context|null = null

generateUri()

API for generating a page uri where the $route parameter is typically an array (a page record) or the page ID

public generateUri(array<string|int, mixed>|string|int|Page $route[, array<string|int, mixed> $parameters = [] ][, string $fragment = '' ][, string $type = '' ]) : UriInterface
Parameters
$route : array<string|int, mixed>|string|int|Page
$parameters : array<string|int, mixed> = []

an array of query parameters which can be built into the URI path, also consider the special handling of "_language"

$fragment : string = ''

additional #my-fragment part

$type : string = ''

see the RouterInterface for possible types

Tags
throws
InvalidRouteArgumentsException
Return values
UriInterface

assertMaximumStaticMappableAmount()

Asserts that possible amount of items in all static and countable mappers (such as StaticRangeMapper) is limited to 10000 in order to avoid brute-force scenarios and the risk of cache-flooding.

protected assertMaximumStaticMappableAmount(Route $route[, array<string|int, mixed> $variableNames = [] ]) : mixed
Parameters
$route : Route
$variableNames : array<string|int, mixed> = []
Tags
throws
OverflowException
todo

with having static route variables, this restriction should be configurable & optional

buildPageArguments()

Builds route arguments. The important part here is to distinguish between static and dynamic arguments. Per default all arguments are dynamic until aspects can be used to really consider them as static (= 1:1 mapping between route value and resulting arguments).

protected buildPageArguments(Route $route, array<string|int, mixed> $results[, array<string|int, mixed> $remainingQueryParameters = [] ]) : PageArguments

Besides that, internal arguments (_route, _controller, _custom, ..) have to be separated since those values are not meant to be used for later processing. Not separating those values might result in invalid cHash.

This method is used during resolving and generation of URLs.

Parameters
$route : Route
$results : array<string|int, mixed>
$remainingQueryParameters : array<string|int, mixed> = []
Return values
PageArguments

filterProcessedParameters()

Determine parameters that have been processed.

protected filterProcessedParameters(Route $route, array<string|int, mixed> $results) : array<string|int, mixed>
Parameters
$route : Route
$results : array<string|int, mixed>
Return values
array<string|int, mixed>

getCacheHashParameters()

protected getCacheHashParameters(int $pageId, PageArguments $arguments) : array<string|int, mixed>
Parameters
$pageId : int
$arguments : PageArguments
Return values
array<string|int, mixed>

getEnhancersForPage()

Fetch possible enhancers + aspects based on the current page configuration and the site configuration put into "routeEnhancers"

protected getEnhancersForPage(int $pageId, SiteLanguage $language) : array<string|int, EnhancerInterface>
Parameters
$pageId : int
$language : SiteLanguage
Return values
array<string|int, EnhancerInterface>

isRouteReallyValidForLanguage()

Request may have been made with default page slug, also we are dealing with a site language variant. To avoid duplicate content, we need to revalidate that the eventually matched language route is really the available page language variant for the current lange. We do this at this late point to minimize the needed database queries instead of checking it for all build page candidates.

protected isRouteReallyValidForLanguage(Route $route, SiteLanguage $siteLanguage) : bool

This is safe, as we can simply drop the route and having a correct page not found action delivered.

Parameters
$route : Route
$siteLanguage : SiteLanguage
Return values
bool

resolveMountPointParameterIntoPageSlug()

When a MP parameter is given, the mount point parameter is resolved, and the slug of the new page is added while the same parts of the original pagePath is removed (before).

protected resolveMountPointParameterIntoPageSlug(int $pageId, string $pagePath, array<string|int, mixed> $mountPointPairs, PageRepository $pageRepository) : string

This way, the subpage to a mounted page has now a different "base" (= prefixed with the slug of the mount point).

This is done recursively when multiple mount point parameter pairs

Parameters
$pageId : int
$pagePath : string

the original path of the page

$mountPointPairs : array<string|int, mixed>

an array with MP pairs (like ['13-3', '4-2'] for recursive mount points)

$pageRepository : PageRepository
Return values
string

resolveType()

Retrieves type from processed route and modifies remaining query parameters.

protected resolveType(Route $route, array<string|int, mixed> &$remainingQueryParameters) : string
Parameters
$route : Route
$remainingQueryParameters : array<string|int, mixed>

reference to remaining query parameters

Return values
string

        
On this page

Search results