PageLinkBuilder extends AbstractTypolinkBuilder

Builds a TypoLink to a certain page

Table of Contents

Properties

$contentObjectRenderer  : ContentObjectRenderer
$typoScriptFrontendController  : TypoScriptFrontendController|null

Methods

__construct()  : mixed
AbstractTypolinkBuilder constructor.
build()  : array<string|int, mixed>|LinkResultInterface
Should be implemented by all subclasses to return an array with three parts: - URL - Link Text (can be modified) - Target (can be modified) - Tag Attributes (optional)
getMountPointParameterFromRootPointMaps()  : string
Initializes the automatically created mountPointMap coming from the "config.MP_mapRootPoints" setting Can be called many times with overhead only the first time since then the map is generated and cached in memory.
getTypoScriptFrontendController()  : TypoScriptFrontendController
buildPageRepository()  : PageRepository
Builds PageRepository instance without depending on global context, e.g.
calculateMountPointParameters()  : string|null
Calculates a possible "&MP=" GET parameter for this link when using mount points.
calculateQueryParameters()  : array<string|int, mixed>
Takes all given options into account to calculate the additional GET parameters for the link, and returns them as a clean array without duplicates.
calculateTargetAttribute()  : string
Returns the final "target" attribute for a link.
calculateUrlFragment()  : string
Checks for the stdWrap "section" which returns the fragment for the generated URL.
encodeFallbackLinkTextIfLinkTextIsEmpty()  : string
Helper method to a fallback method properly encoding HTML.
forceAbsoluteUrl()  : string
Forces a given URL to be absolute.
generateUrlForPageWithSiteConfiguration()  : UriInterface
Create a UriInterface object when linking to a page with a site configuration
getClosestMountPointValueForPage()  : string
The function will do its best to find a MP value that will keep the page id inside the current Mount Point rootline if any.
getCurrentSite()  : SiteInterface|null
Check if we have a site object in the current request. if null, this usually means that this class was called from CLI context.
getCurrentSiteLanguage()  : SiteLanguage|null
If the current request has a site language, this means that the SiteResolver has detected a page with a site configuration and a selected language, so let's choose that one.
getSiteLanguageOfTargetPage()  : SiteLanguage
Fetches the requested language of a site that the link should be built for
initializeMountPointMap()  : array<string|int, mixed>
Create mount point map, based on TypoScript config.MP_mapRootPoints and config.MP_defaults.
isLibParseFuncDefined()  : bool
Determines whether lib.parseFunc is defined.
modifyUrlForAccessRestrictedPage()  : string
If the target page is access restricted, and globally configured to be linked to a different page (e.g. login page) via config.typolinkLinkAccessRestrictedPages = 123 then the URL is modified.
parseFallbackLinkTextIfLinkTextIsEmpty()  : string
Helper method to a fallback method parsing HTML out of it
populateMountPointMapForPageRecursively()  : void
Creating mountPointMap for a certain ID root point.
processUrl()  : string|null
Loops over all configured URL modifier hooks (if available) and returns the generated URL or NULL if no URL was generated.
resolvePage()  : array<string|int, mixed>
Resolves page and if a translated page was found, resolves that to its language parent, adjusts `$linkDetails['pageuid']` (for hook processing) and modifies `$configuration['language']` (for language URL generation).
resolveShortcutPage()  : array<string|int, mixed>
Checks if page is a shortcut, then resolves the target page directly
resolveTargetAttribute()  : string
Creates the value for target="..." in a typolink configuration

Properties

Methods

build()

Should be implemented by all subclasses to return an array with three parts: - URL - Link Text (can be modified) - Target (can be modified) - Tag Attributes (optional)

public build(array<string|int, mixed> &$linkDetails, string $linkText, string $target, array<string|int, mixed> $conf) : array<string|int, mixed>|LinkResultInterface
Parameters
$linkDetails : array<string|int, mixed>

parsed link details by the LinkService

$linkText : string

the link text

$target : string

the target to point to

$conf : array<string|int, mixed>

the TypoLink configuration array

Tags
inheritdoc
throws
UnableToLinkException
Return values
array<string|int, mixed>|LinkResultInterface

an array with three parts (URL, Link Text, Target) - please note that in TYPO3 v12.0. this method will require to return a LinkResultInterface object

getMountPointParameterFromRootPointMaps()

Initializes the automatically created mountPointMap coming from the "config.MP_mapRootPoints" setting Can be called many times with overhead only the first time since then the map is generated and cached in memory.

public getMountPointParameterFromRootPointMaps(int $pageId) : string

Previously located within TemplateService::getFromMPmap()

Parameters
$pageId : int

Page id to return MPvar value for.

Return values
string

buildPageRepository()

Builds PageRepository instance without depending on global context, e.g.

protected buildPageRepository([LanguageAspect|null $languageAspect = null ]) : PageRepository

not automatically overlaying records based on current request language.

Parameters
$languageAspect : LanguageAspect|null = null
Return values
PageRepository

calculateMountPointParameters()

Calculates a possible "&MP=" GET parameter for this link when using mount points.

protected calculateMountPointParameters(array<string|int, mixed> &$page, bool $disableGroupAccessCheck, string $linkText) : string|null
Parameters
$page : array<string|int, mixed>
$disableGroupAccessCheck : bool
$linkText : string
Return values
string|null

calculateQueryParameters()

Takes all given options into account to calculate the additional GET parameters for the link, and returns them as a clean array without duplicates.

protected calculateQueryParameters(array<string|int, mixed> &$conf, array<string|int, mixed> $linkDetails) : array<string|int, mixed>
  • addQueryString
  • additionalParams (+ the ones added from "parameter")
  • config.linkVars
  • type (from "parameter")
  • no_cache

This also does a transformation to remove "L" and "_language" arguments and put this into the $conf array.

Mount Points are added later-on.

Parameters
$conf : array<string|int, mixed>
$linkDetails : array<string|int, mixed>
Return values
array<string|int, mixed>

calculateTargetAttribute()

Returns the final "target" attribute for a link.

protected calculateTargetAttribute(array<string|int, mixed> $page, array<string|int, mixed> $conf, bool $treatAsExternalLink, string $target) : string
Parameters
$page : array<string|int, mixed>
$conf : array<string|int, mixed>
$treatAsExternalLink : bool
$target : string
Return values
string

calculateUrlFragment()

Checks for the stdWrap "section" which returns the fragment for the generated URL.

protected calculateUrlFragment(array<string|int, mixed> $conf, array<string|int, mixed> $linkDetails) : string

Detail: When using a section as an integer, a "c" is added, which referes to a tt_content element. see https://forge.typo3.org/issues/19832 for further work on this limitation.

Parameters
$conf : array<string|int, mixed>
$linkDetails : array<string|int, mixed>
Return values
string

encodeFallbackLinkTextIfLinkTextIsEmpty()

Helper method to a fallback method properly encoding HTML.

protected encodeFallbackLinkTextIfLinkTextIsEmpty(string $originalLinkText, string $fallbackLinkText) : string
Parameters
$originalLinkText : string

the original string, if empty, the fallback link text

$fallbackLinkText : string

the string to be used.

Return values
string

the final text

forceAbsoluteUrl()

Forces a given URL to be absolute.

protected forceAbsoluteUrl(string $url, array<string|int, mixed> $configuration) : string
Parameters
$url : string

The URL to be forced to be absolute

$configuration : array<string|int, mixed>

TypoScript configuration of typolink

Return values
string

The absolute URL

generateUrlForPageWithSiteConfiguration()

Create a UriInterface object when linking to a page with a site configuration

protected generateUrlForPageWithSiteConfiguration(array<string|int, mixed> $page, Site $siteOfTargetPage, array<string|int, mixed> $queryParameters, string $fragment, array<string|int, mixed> $conf) : UriInterface
Parameters
$page : array<string|int, mixed>
$siteOfTargetPage : Site
$queryParameters : array<string|int, mixed>
$fragment : string
$conf : array<string|int, mixed>
Tags
throws
UnableToLinkException
Return values
UriInterface

getClosestMountPointValueForPage()

The function will do its best to find a MP value that will keep the page id inside the current Mount Point rootline if any.

protected getClosestMountPointValueForPage(int $pageId) : string
Parameters
$pageId : int

page id

Return values
string

MP value, prefixed with &MP= (depending on $raw)

getCurrentSite()

Check if we have a site object in the current request. if null, this usually means that this class was called from CLI context.

protected getCurrentSite() : SiteInterface|null
Return values
SiteInterface|null

getCurrentSiteLanguage()

If the current request has a site language, this means that the SiteResolver has detected a page with a site configuration and a selected language, so let's choose that one.

protected getCurrentSiteLanguage() : SiteLanguage|null
Return values
SiteLanguage|null

getSiteLanguageOfTargetPage()

Fetches the requested language of a site that the link should be built for

protected getSiteLanguageOfTargetPage(Site $siteOfTargetPage, string $targetLanguageId) : SiteLanguage
Parameters
$siteOfTargetPage : Site
$targetLanguageId : string

"current" or the languageId

Tags
throws
UnableToLinkException
Return values
SiteLanguage

initializeMountPointMap()

Create mount point map, based on TypoScript config.MP_mapRootPoints and config.MP_defaults.

protected initializeMountPointMap([string $defaultMountPoints = '' ][, string $mapRootPointList = '' ]) : array<string|int, mixed>
Parameters
$defaultMountPoints : string = ''

a string as defined in config.MP_defaults

$mapRootPointList : string = ''

a string as defined in config.MP_mapRootPoints

Return values
array<string|int, mixed>

isLibParseFuncDefined()

Determines whether lib.parseFunc is defined.

protected isLibParseFuncDefined() : bool
Return values
bool

modifyUrlForAccessRestrictedPage()

If the target page is access restricted, and globally configured to be linked to a different page (e.g. login page) via config.typolinkLinkAccessRestrictedPages = 123 then the URL is modified.

protected modifyUrlForAccessRestrictedPage(string $url, array<string|int, mixed> $page, string $overridePageType, array<string|int, mixed> $conf) : string
Parameters
$url : string
$page : array<string|int, mixed>
$overridePageType : string
$conf : array<string|int, mixed>
Return values
string

parseFallbackLinkTextIfLinkTextIsEmpty()

Helper method to a fallback method parsing HTML out of it

protected parseFallbackLinkTextIfLinkTextIsEmpty(string $originalLinkText, string $fallbackLinkText) : string
Parameters
$originalLinkText : string

the original string, if empty, the fallback link text

$fallbackLinkText : string

the string to be used.

Return values
string

the final text

populateMountPointMapForPageRecursively()

Creating mountPointMap for a certain ID root point.

protected populateMountPointMapForPageRecursively(array<string|int, mixed> &$mountPointMap, int $id[, array<string|int, mixed> $MP_array = [] ][, int $level = 0 ]) : void

Previously called TemplateService->initMPmap_create()

Parameters
$mountPointMap : array<string|int, mixed>

the exiting mount point map

$id : int

Root id from which to start map creation.

$MP_array : array<string|int, mixed> = []

MP_array passed from root page.

$level : int = 0

Recursion brake. Incremented for each recursive call. 20 is the limit.

Tags
see
getMountPointParameterFromRootPointMaps()

processUrl()

Loops over all configured URL modifier hooks (if available) and returns the generated URL or NULL if no URL was generated.

protected processUrl(string $context, string $url[, array<string|int, mixed> $typolinkConfiguration = [] ]) : string|null
Parameters
$context : string

The context in which the method is called (e.g. typoLink).

$url : string

The URL that should be processed.

$typolinkConfiguration : array<string|int, mixed> = []

The current link configuration array.

Tags
throws
RuntimeException

if a hook was registered but did not fulfill the correct parameters.

Return values
string|null

Returns NULL if URL was not processed or the processed URL as a string.

resolvePage()

Resolves page and if a translated page was found, resolves that to its language parent, adjusts `$linkDetails['pageuid']` (for hook processing) and modifies `$configuration['language']` (for language URL generation).

protected resolvePage(array<string|int, mixed> &$linkDetails, array<string|int, mixed> &$configuration, bool $disableGroupAccessCheck) : array<string|int, mixed>
Parameters
$linkDetails : array<string|int, mixed>
$configuration : array<string|int, mixed>
$disableGroupAccessCheck : bool
Return values
array<string|int, mixed>

resolveShortcutPage()

Checks if page is a shortcut, then resolves the target page directly

protected resolveShortcutPage(array<string|int, mixed> $page, PageRepository $pageRepository, bool $disableGroupAccessCheck) : array<string|int, mixed>
Parameters
$page : array<string|int, mixed>
$pageRepository : PageRepository
$disableGroupAccessCheck : bool
Return values
array<string|int, mixed>

resolveTargetAttribute()

Creates the value for target="..." in a typolink configuration

protected resolveTargetAttribute(array<string|int, mixed> $conf, string $name[, bool $respectFrameSetOption = false ][, string $fallbackTarget = '' ]) : string
Parameters
$conf : array<string|int, mixed>

the typolink configuration

$name : string

the key, usually "target", "extTarget" or "fileTarget"

$respectFrameSetOption : bool = false

if set, then the fallback is only used as target if the doctype allows it

$fallbackTarget : string = ''

the string to be used when no target is found in the configuration

Return values
string

the value of the target attribute, if there is one


        
On this page

Search results