‪TYPO3CMS  9.5
TYPO3\CMS\Core\Routing\PageRouter Class Reference
Inheritance diagram for TYPO3\CMS\Core\Routing\PageRouter:
TYPO3\CMS\Core\Routing\RouterInterface

Public Member Functions

 __construct (Site $site, Context $context=null)
 
SiteRouteResult matchRequest (ServerRequestInterface $request, RouteResultInterface $previousResult=null)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Routing\RouterInterface
UriInterface generateUri ($route, array $parameters=[], string $fragment='', string $type=self::ABSOLUTE_URL)
 

Protected Member Functions

array getPagesFromDatabaseForCandidates (array $slugCandidates, int $languageId, array $excludeUids=[])
 
array findPageCandidatesOfMountPoint (array $mountPointPage, array $mountedPage, Site $siteOfMountedPage, int $languageId, array $slugCandidates, Context $context)
 
string resolveMountPointParameterIntoPageSlug (int $pageId, string $pagePath, array $mountPointPairs, PageRepository $pageRepository)
 
EnhancerInterface[] getEnhancersForPage (int $pageId, SiteLanguage $language)
 
DecoratingEnhancerInterface[] getDecoratingEnhancers ()
 
string getRoutePathRedecorationPattern ()
 
array getCandidateSlugsFromRoutePath (string $routePath)
 
string generateCacheHash (int $pageId, PageArguments $arguments)
 
array getCacheHashParameters (int $pageId, PageArguments $arguments)
 
PageArguments buildPageArguments (Route $route, array $results, array $remainingQueryParameters=[])
 
string resolveType (Route $route, array &$remainingQueryParameters)
 
 assertMaximumStaticMappableAmount (Route $route, array $variableNames=[])
 
array filterProcessedParameters (Route $route, $results)
 

Protected Attributes

Site $site
 
EnhancerFactory $enhancerFactory
 
AspectFactory $aspectFactory
 
CacheHashCalculator $cacheHashCalculator
 
TYPO3 CMS Core Context Context null $context
 

Additional Inherited Members

- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Routing\RouterInterface
const ABSOLUTE_URL = 'url'
 
const ABSOLUTE_PATH = 'absolute'
 

Detailed Description

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.

Definition at line 74 of file PageRouter.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Routing\PageRouter::__construct ( Site  $site,
Context  $context = null 
)

A page router is always bound to a specific site.

Parameters
Site$site
\TYPO3\CMS\Core\Context\Context | null$context

Definition at line 102 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\$context, and TYPO3\CMS\Core\Routing\PageRouter\$site.

Member Function Documentation

◆ assertMaximumStaticMappableAmount()

TYPO3\CMS\Core\Routing\PageRouter::assertMaximumStaticMappableAmount ( Route  $route,
array  $variableNames = [] 
)
protected

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.

Parameters
Route$route
array$variableNames
Exceptions

Definition at line 897 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\Route\filterAspects().

Referenced by TYPO3\CMS\Core\Routing\PageRouter\buildPageArguments().

◆ buildPageArguments()

PageArguments TYPO3\CMS\Core\Routing\PageRouter::buildPageArguments ( Route  $route,
array  $results,
array  $remainingQueryParameters = [] 
)
protected

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

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
array$results
array$remainingQueryParameters
Returns
PageArguments

Definition at line 843 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\assertMaximumStaticMappableAmount(), TYPO3\CMS\Core\Routing\PageRouter\filterProcessedParameters(), TYPO3\CMS\Core\Routing\Route\getEnhancer(), and TYPO3\CMS\Core\Routing\PageRouter\resolveType().

Referenced by TYPO3\CMS\Core\Routing\PageRouter\matchRequest().

◆ filterProcessedParameters()

array TYPO3\CMS\Core\Routing\PageRouter::filterProcessedParameters ( Route  $route,
  $results 
)
protected

Determine parameters that have been processed.

Parameters
Route$route
array$results
Returns
‪array

Definition at line 928 of file PageRouter.php.

Referenced by TYPO3\CMS\Core\Routing\PageRouter\buildPageArguments().

◆ findPageCandidatesOfMountPoint()

array TYPO3\CMS\Core\Routing\PageRouter::findPageCandidatesOfMountPoint ( array  $mountPointPage,
array  $mountedPage,
Site  $siteOfMountedPage,
int  $languageId,
array  $slugCandidates,
Context  $context 
)
protected

Check if the page candidate is a mount point, if so, we need to re-start the slug candidates procedure with the mount point as a prefix (= context of the subpage).

Before doing the slugCandidates are adapted to remove the slug of the mount point (actively moving the pointer of the path to strip away the existing prefix), then checking for more pages.

Once possible candidates are found, the slug prefix needs to be re-added so the PageRouter finds the page, with an additional 'MPvar' attribute. However, all page candidates needs to be checked if they are connected in the proper mount page.

Parameters
array$mountPointPage‪the page with doktype=7
array$mountedPage‪the target page where the mountpoint is pointing to
Site$siteOfMountedPage‪the site of the target page, which could be different from the current page
int$languageId‪the current language id
array$slugCandidates‪the existing slug candidates that were looked for previously
Context$context
Returns
‪array more candidates

Definition at line 545 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\$context.

Referenced by TYPO3\CMS\Core\Routing\PageRouter\getPagesFromDatabaseForCandidates().

◆ generateCacheHash()

string TYPO3\CMS\Core\Routing\PageRouter::generateCacheHash ( int  $pageId,
PageArguments  $arguments 
)
protected
Parameters
int$pageId
PageArguments$arguments
Returns
‪string

Definition at line 806 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\getCacheHashParameters().

◆ getCacheHashParameters()

array TYPO3\CMS\Core\Routing\PageRouter::getCacheHashParameters ( int  $pageId,
PageArguments  $arguments 
)
protected
Parameters
int$pageId
PageArguments$arguments
Returns
‪array

Definition at line 818 of file PageRouter.php.

Referenced by TYPO3\CMS\Core\Routing\PageRouter\generateCacheHash().

◆ getCandidateSlugsFromRoutePath()

array TYPO3\CMS\Core\Routing\PageRouter::getCandidateSlugsFromRoutePath ( string  $routePath)
protected

Returns possible URL parts for a string like /home/about-us/offices/ or /home/about-us/offices.json to return.

/home/about-us/offices/ /home/about-us/offices.json /home/about-us/offices /home/about-us/ /home/about-us /home/ /home /

Parameters
string$routePath
Returns
‪array

Definition at line 776 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\getRoutePathRedecorationPattern().

Referenced by TYPO3\CMS\Core\Routing\PageRouter\matchRequest().

◆ getDecoratingEnhancers()

DecoratingEnhancerInterface [] TYPO3\CMS\Core\Routing\PageRouter::getDecoratingEnhancers ( )
protected

Resolves decorating enhancers without having aspects assigned. These instances are used to pre-process URL path and MUST NOT be used for actually resolving or generating URL parameters.

Returns
‪DecoratingEnhancerInterface[]

Definition at line 725 of file PageRouter.php.

Referenced by TYPO3\CMS\Core\Routing\PageRouter\getRoutePathRedecorationPattern().

◆ getEnhancersForPage()

EnhancerInterface [] TYPO3\CMS\Core\Routing\PageRouter::getEnhancersForPage ( int  $pageId,
SiteLanguage  $language 
)
protected

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

Parameters
int$pageId
SiteLanguage$language
Returns
‪EnhancerInterface[]

Definition at line 695 of file PageRouter.php.

Referenced by TYPO3\CMS\Core\Routing\PageRouter\matchRequest().

◆ getPagesFromDatabaseForCandidates()

array TYPO3\CMS\Core\Routing\PageRouter::getPagesFromDatabaseForCandidates ( array  $slugCandidates,
int  $languageId,
array  $excludeUids = [] 
)
protected

Check for records in the database which matches one of the slug candidates.

Parameters
array$slugCandidates
int$languageId
array$excludeUids‪when called recursively this is the mountpoint parameter of the original prefix
Returns
‪array
Exceptions
SiteNotFoundException

Definition at line 396 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\$context, TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_MOUNTPOINT, TYPO3\CMS\Core\Routing\PageRouter\findPageCandidatesOfMountPoint(), and TYPO3\CMS\Core\Context\Context\getPropertyFromAspect().

Referenced by TYPO3\CMS\Core\Routing\PageRouter\matchRequest().

◆ getRoutePathRedecorationPattern()

string TYPO3\CMS\Core\Routing\PageRouter::getRoutePathRedecorationPattern ( )
protected

Gets all patterns that can be used to redecorate (undecorate) a potential previously decorated route path.

Returns
‪string regular expression pattern capable of redecorating

Definition at line 744 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\getDecoratingEnhancers(), and TYPO3\CMS\Core\Routing\Enhancer\DecoratingEnhancerInterface\getRoutePathRedecorationPattern().

Referenced by TYPO3\CMS\Core\Routing\PageRouter\getCandidateSlugsFromRoutePath().

◆ matchRequest()

SiteRouteResult TYPO3\CMS\Core\Routing\PageRouter::matchRequest ( ServerRequestInterface  $request,
RouteResultInterface  $previousResult = null 
)

◆ resolveMountPointParameterIntoPageSlug()

string TYPO3\CMS\Core\Routing\PageRouter::resolveMountPointParameterIntoPageSlug ( int  $pageId,
string  $pagePath,
array  $mountPointPairs,
PageRepository  $pageRepository 
)
protected

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). 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
int$pageId
string$pagePath‪the original path of the page
array$mountPointPairs‪an array with MP pairs (like ['13-3', '4-2'] for recursive mount points)
PageRepository$pageRepository
Returns
‪string

Definition at line 642 of file PageRouter.php.

References TYPO3\CMS\Frontend\Page\PageRepository\getMountPointInfo(), and TYPO3\CMS\Frontend\Page\PageRepository\getPage().

◆ resolveType()

string TYPO3\CMS\Core\Routing\PageRouter::resolveType ( Route  $route,
array &  $remainingQueryParameters 
)
protected

Retrieves type from processed route and modifies remaining query parameters.

Parameters
Route$route
array$remainingQueryParameters‪reference to remaining query parameters
Returns
‪string

Definition at line 873 of file PageRouter.php.

Referenced by TYPO3\CMS\Core\Routing\PageRouter\buildPageArguments().

Member Data Documentation

◆ $aspectFactory

AspectFactory TYPO3\CMS\Core\Routing\PageRouter::$aspectFactory
protected

Definition at line 86 of file PageRouter.php.

◆ $cacheHashCalculator

CacheHashCalculator TYPO3\CMS\Core\Routing\PageRouter::$cacheHashCalculator
protected

Definition at line 90 of file PageRouter.php.

◆ $context

◆ $enhancerFactory

EnhancerFactory TYPO3\CMS\Core\Routing\PageRouter::$enhancerFactory
protected

Definition at line 82 of file PageRouter.php.

◆ $site

Site TYPO3\CMS\Core\Routing\PageRouter::$site
protected

Definition at line 78 of file PageRouter.php.

Referenced by TYPO3\CMS\Core\Routing\PageRouter\__construct().