SiteMatcher implements SingletonInterface
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.
Table of Contents
Interfaces
- SingletonInterface
- "empty" interface for singletons (marker interface pattern)
Properties
Methods
- __construct() : mixed
- matchByPageId() : SiteInterface
- If a given page ID is handed in, a Site/NullSite is returned.
- matchRequest() : RouteResultInterface
- First, it is checked, if a "id" GET/POST parameter is found.
- refresh() : mixed
- Only used when a page is moved but the pseudo site caches has this information hard-coded, so the caches need to be flushed.
- canonicalizeUri() : UriInterface
- Remove script file name (index.php) from request uri
- getRouteCollectionForAllSites() : RouteCollection
- Returns a Symfony RouteCollection containing all routes to all sites.
- matchSiteByQueryParams() : SiteRouteResult
- matchSiteByUri() : SiteRouteResult
- resolveLanguageIdQueryParam() : positive-int|null
- resolvePageIdQueryParam() : positive-int|null
Properties
$features read-only
        protected
            Features
    $features
    
    
    
    
    
    
$finder read-only
        protected
            SiteFinder
    $finder
    
    
    
    
    
    
$requestContextFactory read-only
        protected
            RequestContextFactory
    $requestContextFactory
    
    
    
    
    
    
Methods
__construct()
    public
                    __construct(Features $features, SiteFinder $finder, RequestContextFactory $requestContextFactory) : mixed
    Parameters
- $features : Features
- $finder : SiteFinder
- $requestContextFactory : RequestContextFactory
matchByPageId()
If a given page ID is handed in, a Site/NullSite is returned.
    public
                    matchByPageId(int $pageId[, array<string|int, mixed>|null $rootLine = null ]) : SiteInterface
    Parameters
- $pageId : int
- 
                    uid of a page in default language 
- $rootLine : array<string|int, mixed>|null = null
- 
                    an alternative root line, if already at and. 
Return values
SiteInterfacematchRequest()
First, it is checked, if a "id" GET/POST parameter is found.
    public
                    matchRequest(ServerRequestInterface $request) : RouteResultInterface
    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
- $request : ServerRequestInterface
Return values
RouteResultInterfacerefresh()
Only used when a page is moved but the pseudo site caches has this information hard-coded, so the caches need to be flushed.
    public
                    refresh() : mixed
    Tags
canonicalizeUri()
Remove script file name (index.php) from request uri
    protected
                    canonicalizeUri(UriInterface $uri, ServerRequestInterface $request) : UriInterface
    Parameters
- $uri : UriInterface
- $request : ServerRequestInterface
Return values
UriInterfacegetRouteCollectionForAllSites()
Returns a Symfony RouteCollection containing all routes to all sites.
    protected
                    getRouteCollectionForAllSites() : RouteCollection
    Return values
RouteCollectionmatchSiteByQueryParams()
    protected
                    matchSiteByQueryParams(int $pageId, int $languageId, SiteRouteResult $fallback, UriInterface $uri) : SiteRouteResult
    Parameters
- $pageId : int
- $languageId : int
- $fallback : SiteRouteResult
- $uri : UriInterface
Return values
SiteRouteResultmatchSiteByUri()
    protected
                    matchSiteByUri(UriInterface $uri, ServerRequestInterface $request) : SiteRouteResult
    Parameters
- $uri : UriInterface
- $request : ServerRequestInterface
Return values
SiteRouteResultresolveLanguageIdQueryParam()
    protected
                    resolveLanguageIdQueryParam(ServerRequestInterface $request) : positive-int|null
    Parameters
- $request : ServerRequestInterface
Return values
positive-int|nullresolvePageIdQueryParam()
    protected
                    resolvePageIdQueryParam(ServerRequestInterface $request) : positive-int|null
    Parameters
- $request : ServerRequestInterface