‪TYPO3CMS  9.5
TYPO3\CMS\Core\Routing\SiteMatcher Class Reference
Inheritance diagram for TYPO3\CMS\Core\Routing\SiteMatcher:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (SiteFinder $finder=null)
 
 refresh ()
 
RouteResultInterface matchRequest (ServerRequestInterface $request)
 
SiteInterface matchByPageId (int $pageId, array $rootLine=null)
 

Protected Member Functions

RouteCollection getRouteCollectionForAllSites ()
 
RouteCollection getRouteCollectionForVisibleSysDomains ()
 
RouteCollection createRouteCollectionFromGroupedRoutes (array $groupedRoutes)
 

Protected Attributes

SiteFinder $finder
 
PseudoSiteFinder $pseudoSiteFinder
 

Detailed Description

Returns a site or pseudo-site (with sys_domain records) based on a given request.

The main usage is the ->matchRequest() functionality, which receives a request object and boots up Symfony Routing to find the proper route with its defaults / attributes.

On top, this is also commonly used throughout TYPO3 to fetch a site by a given pageId. ->matchPageId().

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

Please note that the site matcher will be probably cease to exist and adapted to the SiteFinder concept when Pseudo-Site handling will be removed.

Definition at line 52 of file SiteMatcher.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Routing\SiteMatcher::__construct ( SiteFinder  $finder = null)

Injects necessary objects. PseudoSiteFinder is not injectable as this will be become obsolete in the future.

Parameters
SiteFinder | null$finder

Definition at line 67 of file SiteMatcher.php.

References TYPO3\CMS\Core\Routing\SiteMatcher\$finder.

Member Function Documentation

◆ createRouteCollectionFromGroupedRoutes()

RouteCollection TYPO3\CMS\Core\Routing\SiteMatcher::createRouteCollectionFromGroupedRoutes ( array  $groupedRoutes)
protected

As the {tail} parameter is greedy, it needs to be ensured that the one with the most specific part matches first.

Parameters
array$groupedRoutes
Returns
RouteCollection

Definition at line 313 of file SiteMatcher.php.

Referenced by TYPO3\CMS\Core\Routing\SiteMatcher\getRouteCollectionForAllSites(), and TYPO3\CMS\Core\Routing\SiteMatcher\getRouteCollectionForVisibleSysDomains().

◆ getRouteCollectionForAllSites()

RouteCollection TYPO3\CMS\Core\Routing\SiteMatcher::getRouteCollectionForAllSites ( )
protected

◆ getRouteCollectionForVisibleSysDomains()

RouteCollection TYPO3\CMS\Core\Routing\SiteMatcher::getRouteCollectionForVisibleSysDomains ( )
protected

Return the page ID (pid) of a sys_domain record, based on a request object, does the infamous "recursive domain search", to also detect if the domain is like "abc.def.example.com" even if the sys_domain entry is "example.com".

Returns
RouteCollection

Definition at line 277 of file SiteMatcher.php.

References TYPO3\CMS\Core\Routing\SiteMatcher\createRouteCollectionFromGroupedRoutes().

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

◆ matchByPageId()

SiteInterface TYPO3\CMS\Core\Routing\SiteMatcher::matchByPageId ( int  $pageId,
array  $rootLine = null 
)

If a given page ID is handed in, a Site/PseudoSite/NullSite is returned.

Parameters
int$pageId‪uid of a page in default language
array | null$rootLine‪an alternative root line, if already at and.
Returns
‪SiteInterface
Exceptions
SiteNotFoundException

Definition at line 221 of file SiteMatcher.php.

Referenced by TYPO3\CMS\Frontend\DataProcessing\SiteProcessor\getCurrentSite().

◆ matchRequest()

RouteResultInterface TYPO3\CMS\Core\Routing\SiteMatcher::matchRequest ( ServerRequestInterface  $request)

First, it is checked, if a "id" GET/POST parameter is found. If it is, we check for a valid site mounted there.

If it isn't the quest continues by validating the whole request URL and validating against all available site records (and their language prefixes).

If none is found, the "legacy" handling is checked for - checking for all pseudo-sites with a sys_domain record, and match against them.

Parameters
ServerRequestInterface$request
Returns
RouteResultInterface

Definition at line 102 of file SiteMatcher.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Routing\SiteMatcher\getRouteCollectionForAllSites(), TYPO3\CMS\Core\Routing\SiteMatcher\getRouteCollectionForVisibleSysDomains(), and TYPO3\CMS\Core\Utility\HttpUtility\idn_to_ascii().

◆ refresh()

TYPO3\CMS\Core\Routing\SiteMatcher::refresh ( )

Only used when a page is moved but the pseudo site caches has this information hard-coded, so the caches need to be flushed.

Exceptions

Definition at line 80 of file SiteMatcher.php.

References TYPO3\CMS\Core\Utility\RootlineUtility\purgeCaches().

Member Data Documentation

◆ $finder

SiteFinder TYPO3\CMS\Core\Routing\SiteMatcher::$finder
protected

Definition at line 56 of file SiteMatcher.php.

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

◆ $pseudoSiteFinder

PseudoSiteFinder TYPO3\CMS\Core\Routing\SiteMatcher::$pseudoSiteFinder
protected

Definition at line 60 of file SiteMatcher.php.