PageSlugCandidateProvider

class \TYPO3\CMS\Core\Routing\PageSlugCandidateProvider

Provides possible pages (from the database) that _could_ match a certain URL path, but also works for fetching the best "slug" value for multi-lingual pages with a specific language requested.

Table of Contents

Properties

$context  : Context
$enhancerFactory  : EnhancerFactory
$languageIdsOfFallbackChain  : int[]
The requested language followed by its fallback languages
$site  : Site

Methods

__construct()  : mixed
getCandidatesForPath()  : array<int, array<string, mixed>>
Fetches an array of possible URLs that match the current site + language (incl. fallbacks)
getRealPageIdForPageIdAsPossibleCandidate()  : int|null
Fetches the page without any language or other hidden/enable fields, but only takes "deleted" and "workspace" into account, as all other things will be evaluated later.
findPageCandidatesOfMountPoint()  : array
Check if the page candidate is a mount point, if so, we need to re-start the slug candidates procedure with the mount point as a prefix (= context of the subpage).
findPageCandidatesOfMountPointInFallbackChain()  : array
A mount point page without a translation is only found in a fallback language of the requested language, while the pages of the mounted tree may be translated into the requested language. Their candidates are therefore looked up in all languages of the fallback chain, starting with the requested language.
getCandidateSlugsFromRoutePath()  : string[]
Returns possible URL parts for a string like /home/about-us/offices/ or /home/about-us/offices.json to return.
getDecoratingEnhancers()  : DecoratingEnhancerInterface[]
Resolves decorating enhancers without having aspects assigned. These instances are used to pre-process URL path and MUST NOT be used for actually resolving or generating URL parameters.
getPagesFromDatabaseForCandidates()  : array[]|array
Check for records in the database which matches one of the slug candidates.
getRoutePathRedecorationPattern()  : string
Gets all patterns that can be used to redecorate (undecorate) a potential previously decorated route path.

Properties

$languageIdsOfFallbackChain

The requested language followed by its fallback languages

protected int[] $languageIdsOfFallbackChain = []

Methods

getCandidatesForPath()

Fetches an array of possible URLs that match the current site + language (incl. fallbacks)

public getCandidatesForPath(string $urlPath, SiteLanguage $language) : array<int, array<string, mixed>>

Parameters

$urlPath : string
$language : SiteLanguage

Return values

array<int, array<string, mixed>>

getRealPageIdForPageIdAsPossibleCandidate()

Fetches the page without any language or other hidden/enable fields, but only takes "deleted" and "workspace" into account, as all other things will be evaluated later.

public getRealPageIdForPageIdAsPossibleCandidate(int $pageId) : int|null

This is only needed for resolving the ACTUAL Page Id when index.php?id=13 was given

Should be rebuilt to return the actual Page ID considering the online ID of the page.

Parameters

$pageId : int

Return values

int|null

findPageCandidatesOfMountPoint()

Check if the page candidate is a mount point, if so, we need to re-start the slug candidates procedure with the mount point as a prefix (= context of the subpage).

protected findPageCandidatesOfMountPoint(array $mountPointPage, array $mountedPage, Site $siteOfMountedPage, int $languageId, array $slugCandidates) : array

Before doing the slugCandidates are adapted to remove the slug of the mount point (actively moving the pointer of the path to strip away the existing prefix), then checking for more pages.

Once possible candidates are found, the slug prefix needs to be re-added so the PageRouter finds the page, with an additional 'MPvar' attribute. However, all page candidates needs to be checked if they are connected in the proper mount page.

Parameters

$mountPointPage : array

the page with doktype=7

$mountedPage : array

the target page where the mountpoint is pointing to

$siteOfMountedPage : Site

the site of the target page, which could be different from the current page

$languageId : int

the current language id

$slugCandidates : array

the existing slug candidates that were looked for previously

Return values

array —

more candidates

findPageCandidatesOfMountPointInFallbackChain()

A mount point page without a translation is only found in a fallback language of the requested language, while the pages of the mounted tree may be translated into the requested language. Their candidates are therefore looked up in all languages of the fallback chain, starting with the requested language.

protected findPageCandidatesOfMountPointInFallbackChain(array $mountPointPage, array $mountedPage, Site $siteOfMountedPage, int $languageId, array $slugCandidates, PageRepository $pageRepository) : array

Parameters

$mountPointPage : array

the page with doktype=7, in language $languageId

$mountedPage : array

the target page of the mount point, in language $languageId

$siteOfMountedPage : Site
$languageId : int

the language the mount point page was found in

$slugCandidates : array
$pageRepository : PageRepository

Return values

array

getCandidateSlugsFromRoutePath()

Returns possible URL parts for a string like /home/about-us/offices/ or /home/about-us/offices.json to return.

protected getCandidateSlugsFromRoutePath(string $routePath) : string[]

/home/about-us/offices/ /home/about-us/offices.json /home/about-us/offices /home/about-us/ /home/about-us /home/ /home /

Parameters

$routePath : string

Return values

string[]

getDecoratingEnhancers()

Resolves decorating enhancers without having aspects assigned. These instances are used to pre-process URL path and MUST NOT be used for actually resolving or generating URL parameters.

protected getDecoratingEnhancers() : DecoratingEnhancerInterface[]

Return values

DecoratingEnhancerInterface[]

getPagesFromDatabaseForCandidates()

Check for records in the database which matches one of the slug candidates.

protected getPagesFromDatabaseForCandidates(array $slugCandidates, int $languageId[, array $excludeUids = [] ]) : array[]|array

Parameters

$slugCandidates : array
$languageId : int
$excludeUids : array = []

when called recursively this is the mountpoint parameter of the original prefix

Tags

throws
SiteNotFoundException

Return values

array[]|array

getRoutePathRedecorationPattern()

Gets all patterns that can be used to redecorate (undecorate) a potential previously decorated route path.

protected getRoutePathRedecorationPattern() : string

Return values

string —

regular expression pattern capable of redecorating

On this page