AbstractTypolinkBuilder

abstract class \TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder

Abstract class to provide proper helper for most types necessary Hands in the ContentObject and TSFE which are needed here for all the stdWrap magic.

Table of Contents

Properties

$contentObjectRenderer  : ContentObjectRenderer
$typoScriptFrontendController  : TypoScriptFrontendController|null

Methods

__construct()  : mixed
AbstractTypolinkBuilder constructor.
build()  : array|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)
getTypoScriptFrontendController()  : TypoScriptFrontendController
encodeFallbackLinkTextIfLinkTextIsEmpty()  : string
Helper method to a fallback method properly encoding HTML.
forceAbsoluteUrl()  : string
Forces a given URL to be absolute.
isLibParseFuncDefined()  : bool
Determines whether lib.parseFunc is defined.
parseFallbackLinkTextIfLinkTextIsEmpty()  : string
Helper method to a fallback method parsing HTML out of it
processUrl()  : string|null
Loops over all configured URL modifier hooks (if available) and returns the generated URL or NULL if no URL was generated.
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 abstract build(array &$linkDetails, string $linkText, string $target, array $conf) : array|LinkResultInterface

Parameters

$linkDetails : array

parsed link details by the LinkService

$linkText : string

the link text

$target : string

the target to point to

$conf : array

the TypoLink configuration array

Return values

array|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

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 $configuration) : string

Parameters

$url : string

The URL to be forced to be absolute

$configuration : array

TypoScript configuration of typolink

Return values

string —

The absolute URL

isLibParseFuncDefined()

Determines whether lib.parseFunc is defined.

protected isLibParseFuncDefined() : bool

Return values

bool

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

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 $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 = []

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.

resolveTargetAttribute()

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

protected resolveTargetAttribute(array $conf, string $name[, bool $respectFrameSetOption = false ][, string $fallbackTarget = '' ]) : string

Parameters

$conf : array

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