‪TYPO3CMS  ‪main
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)
 
RouteResultInterface PageArguments matchRequest (ServerRequestInterface $request, RouteResultInterface $previousResult=null)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Routing\RouterInterface
 generateUri ($route, array $parameters=[], string $fragment='', string $type=self::ABSOLUTE_URL)
 

Protected Member Functions

 resolveMountPointParameterIntoPageSlug (int $pageId, string $pagePath, array $mountPointPairs, PageRepository $pageRepository)
 
EnhancerInterface[] getEnhancersForPage (int $pageId, SiteLanguage $language)
 
 generateCacheHash (int $pageId, PageArguments $arguments)
 
 getCacheHashParameters (int $pageId, PageArguments $arguments)
 
 buildPageArguments (Route $route, array $results, array $remainingQueryParameters=[])
 
 resolveType (Route $route, array &$remainingQueryParameters)
 
 assertMaximumStaticMappableAmount (Route $route, array $variableNames=[])
 
 filterProcessedParameters (Route $route, $results)
 
 getSlugCandidateProvider (Context $context)
 
 isRouteReallyValidForLanguage (Route $route, SiteLanguage $siteLanguage)
 

Protected Attributes

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

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.

Definition at line 82 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.

Exceptions

Definition at line 569 of file PageRouter.php.

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

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

◆ buildPageArguments()

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

Definition at line 513 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()

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

Determine parameters that have been processed.

Parameters
array$results

Definition at line 598 of file PageRouter.php.

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

◆ generateCacheHash()

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

◆ getCacheHashParameters()

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

Definition at line 489 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"

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

◆ isRouteReallyValidForLanguage()

TYPO3\CMS\Core\Routing\PageRouter::isRouteReallyValidForLanguage ( Route  $route,
SiteLanguage  $siteLanguage 
)
protected

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.

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

Definition at line 624 of file PageRouter.php.

References $GLOBALS, and TYPO3\CMS\Core\Site\Entity\SiteLanguage\getLanguageId().

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

◆ matchRequest()

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

◆ resolveMountPointParameterIntoPageSlug()

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

Definition at line 408 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()

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

Retrieves type from processed route and modifies remaining query parameters.

Parameters
array$remainingQueryParameters‪reference to remaining query parameters

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

◆ $cacheHashCalculator

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

Definition at line 75 of file PageRouter.php.

◆ $context

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

◆ $enhancerFactory

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

Definition at line 73 of file PageRouter.php.

◆ $requestContextFactory

RequestContextFactory TYPO3\CMS\Core\Routing\PageRouter::$requestContextFactory
protected

Definition at line 77 of file PageRouter.php.

◆ $site

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

Definition at line 72 of file PageRouter.php.

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