‪TYPO3CMS  10.4
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

string resolveMountPointParameterIntoPageSlug (int $pageId, string $pagePath, array $mountPointPairs, PageRepository $pageRepository)
 
EnhancerInterface[] getEnhancersForPage (int $pageId, SiteLanguage $language)
 
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)
 
 getSlugCandidateProvider (Context $context)
 

Protected Attributes

Site $site
 
EnhancerFactory $enhancerFactory
 
AspectFactory $aspectFactory
 
CacheHashCalculator $cacheHashCalculator
 
TYPO3 CMS Core Context Context $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 70 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 98 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 579 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 524 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 610 of file PageRouter.php.

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

◆ generateCacheHash()

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

Definition at line 487 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 499 of file PageRouter.php.

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

◆ 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 459 of file PageRouter.php.

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

◆ getSlugCandidateProvider()

TYPO3\CMS\Core\Routing\PageRouter::getSlugCandidateProvider ( Context  $context)
protected

◆ matchRequest()

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

Finds a RouteResult based on the given request.

Parameters
ServerRequestInterface$request
RouteResultInterface | SiteRouteResult | null$previousResult
Returns
SiteRouteResult
Exceptions
RouteNotFoundException

Implements TYPO3\CMS\Core\Routing\RouterInterface.

Definition at line 115 of file PageRouter.php.

References TYPO3\CMS\Core\Routing\PageRouter\buildPageArguments(), TYPO3\CMS\Core\Routing\PageRouter\getEnhancersForPage(), and TYPO3\CMS\Core\Routing\PageRouter\getSlugCandidateProvider().

◆ 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 406 of file PageRouter.php.

References TYPO3\CMS\Core\Domain\Repository\PageRepository\getMountPointInfo(), TYPO3\CMS\Core\Domain\Repository\PageRepository\getPage(), and TYPO3\CMS\Core\Utility\GeneralUtility\intExplode().

◆ 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 555 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 82 of file PageRouter.php.

◆ $cacheHashCalculator

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

Definition at line 86 of file PageRouter.php.

◆ $context

TYPO3 CMS Core Context Context TYPO3\CMS\Core\Routing\PageRouter::$context
protected

◆ $enhancerFactory

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

Definition at line 78 of file PageRouter.php.

◆ $site

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

Definition at line 74 of file PageRouter.php.

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