‪TYPO3CMS  11.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 ()
 
positive int resolvePageIdQueryParam (ServerRequestInterface $request)
 
positive int resolveLanguageIdQueryParam (ServerRequestInterface $request)
 
 canonicalizeUri (UriInterface $uri, ServerRequestInterface $request)
 
 matchSiteByUri (UriInterface $uri, ServerRequestInterface $request)
 
 matchSiteByQueryParams (int $pageId, int $languageId, SiteRouteResult $fallback, UriInterface $uri)
 

Protected Attributes

SiteFinder $finder
 

Detailed Description

Returns a site 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 51 of file SiteMatcher.php.

Constructor & Destructor Documentation

◆ __construct()

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

Injects necessary objects.

Parameters
SiteFinder | null$finder

Definition at line 62 of file SiteMatcher.php.

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

Member Function Documentation

◆ canonicalizeUri()

TYPO3\CMS\Core\Routing\SiteMatcher::canonicalizeUri ( UriInterface  $uri,
ServerRequestInterface  $request 
)
protected

Remove script file name (index.php) from request uri

Definition at line 219 of file SiteMatcher.php.

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

◆ getRouteCollectionForAllSites()

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

Returns a Symfony RouteCollection containing all routes to all sites.

Returns
RouteCollection

Definition at line 153 of file SiteMatcher.php.

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

◆ matchByPageId()

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

If a given page ID is handed in, a Site/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 139 of file SiteMatcher.php.

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

Parameters
ServerRequestInterface$request
Returns
RouteResultInterface

Definition at line 91 of file SiteMatcher.php.

References TYPO3\CMS\Core\Routing\SiteMatcher\canonicalizeUri(), TYPO3\CMS\Core\Routing\SiteMatcher\matchSiteByQueryParams(), TYPO3\CMS\Core\Routing\SiteMatcher\matchSiteByUri(), TYPO3\CMS\Core\Routing\SiteMatcher\resolveLanguageIdQueryParam(), and TYPO3\CMS\Core\Routing\SiteMatcher\resolvePageIdQueryParam().

◆ matchSiteByQueryParams()

TYPO3\CMS\Core\Routing\SiteMatcher::matchSiteByQueryParams ( int  $pageId,
int  $languageId,
SiteRouteResult  $fallback,
UriInterface  $uri 
)
protected

Definition at line 269 of file SiteMatcher.php.

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

◆ matchSiteByUri()

TYPO3\CMS\Core\Routing\SiteMatcher::matchSiteByUri ( UriInterface  $uri,
ServerRequestInterface  $request 
)
protected

◆ 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 74 of file SiteMatcher.php.

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

◆ resolveLanguageIdQueryParam()

positive int TYPO3\CMS\Core\Routing\SiteMatcher::resolveLanguageIdQueryParam ( ServerRequestInterface  $request)
protected
Returns
‪?positive-int

Definition at line 207 of file SiteMatcher.php.

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

◆ resolvePageIdQueryParam()

positive int TYPO3\CMS\Core\Routing\SiteMatcher::resolvePageIdQueryParam ( ServerRequestInterface  $request)
protected
Returns
‪?positive-int

Definition at line 195 of file SiteMatcher.php.

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

Member Data Documentation

◆ $finder

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

Definition at line 55 of file SiteMatcher.php.

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