LinkFactory

readonly class \TYPO3\CMS\Frontend\Typolink\LinkFactory

Uses
DefaultJavaScriptAssetTrait

Main class for generating any kind of frontend links.

Contains all logic for the infamous typolink() functionality.

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Properties

$eventDispatcher  : EventDispatcherInterface
$linkService  : LinkService
$logger  : LoggerInterface
$typoLinkCodecService  : TypoLinkCodecService

Methods

__construct()  : mixed
create()  : LinkResultInterface
Main method to create links from typolink strings and configuration.
createUri()  : LinkResultInterface
Creates a link result for a given URL (usually something like "19 _blank css-class "testtitle with whitespace" &X=y").
addAdditionalAnchorTagAttributes()  : LinkResultInterface
An abstraction method to add parameters to an A tag.
addDefaultFrontendJavaScript()  : void
addJavaScriptOpenWindowInformationAttributes()  : LinkResultInterface
addSecurityRelValues()  : LinkResultInterface
buildLinkResult()  : LinkResultInterface
Dispatches the linkDetails + configuration to the concrete typolink Builder (page, email etc) and returns a LinkResultInterface.
isInternalUrl()  : bool
Checks whether the given url is an internal url.
resolveLinkDetails()  : array|null
Creates $linkDetails out of the link parameter so the concrete LinkBuilder can be resolved.
resolveTypolinkParameterString()  : array
Does the magic to split the full "typolink" string like "15,13 _blank myclass &more=1" into separate parts
shallExportDefaultFrontendJavaScript()  : bool
shallRemoveDefaultFrontendJavaScript()  : bool

Properties

$eventDispatcher

protected EventDispatcherInterface $eventDispatcher

Methods

createUri()

Creates a link result for a given URL (usually something like "19 _blank css-class "testtitle with whitespace" &X=y").

public createUri(string $urlParameter[, ContentObjectRenderer|null $contentObjectRenderer = null ]) : LinkResultInterface

Helpful if you want to create any kind of URL (also possible in TYPO3 Backend).

Parameters

$urlParameter : string
$contentObjectRenderer : ContentObjectRenderer|null = null

Return values

LinkResultInterface

addAdditionalAnchorTagAttributes()

An abstraction method to add parameters to an A tag.

protected addAdditionalAnchorTagAttributes(LinkResultInterface $linkResult, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface

Uses the ATagParams property, also includes the global TypoScript config.ATagParams

Parameters

$linkResult : LinkResultInterface
$linkConfiguration : array
$contentObjectRenderer : ContentObjectRenderer

Return values

LinkResultInterface

addDefaultFrontendJavaScript()

protected addDefaultFrontendJavaScript(ServerRequestInterface $request) : void

Parameters

$request : ServerRequestInterface

buildLinkResult()

Dispatches the linkDetails + configuration to the concrete typolink Builder (page, email etc) and returns a LinkResultInterface.

protected buildLinkResult(string $linkText, array $linkDetails, string $target, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface

Parameters

$linkText : string
$linkDetails : array
$target : string
$linkConfiguration : array
$contentObjectRenderer : ContentObjectRenderer

Return values

LinkResultInterface

isInternalUrl()

Checks whether the given url is an internal url.

protected isInternalUrl(string $url, ServerRequestInterface $request) : bool

It will check the host part only.

Note: It would be good to move this to EXT:core/Classes/Site which accepts also a PSR-7 request and also accepts a PSR-7 Uri.

Parameters

$url : string
$request : ServerRequestInterface

Return values

bool

resolveLinkDetails()

Creates $linkDetails out of the link parameter so the concrete LinkBuilder can be resolved.

protected resolveLinkDetails(string $linkParameter, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : array|null

Parameters

$linkParameter : string
$linkConfiguration : array
$contentObjectRenderer : ContentObjectRenderer

Return values

array|null

resolveTypolinkParameterString()

Does the magic to split the full "typolink" string like "15,13 _blank myclass &more=1" into separate parts

protected resolveTypolinkParameterString(string $mixedLinkParameter[, array &$linkConfiguration = [] ]) : array

Parameters

$mixedLinkParameter : string

destination data like "15,13 _blank myclass &more=1" used to create the link

$linkConfiguration : array = []

TypoScript configuration

Return values

array

shallExportDefaultFrontendJavaScript()

protected shallExportDefaultFrontendJavaScript(ServerRequestInterface $request) : bool

Parameters

$request : ServerRequestInterface

Return values

bool

shallRemoveDefaultFrontendJavaScript()

protected shallRemoveDefaultFrontendJavaScript(ServerRequestInterface $request) : bool

Parameters

$request : ServerRequestInterface

Return values

bool
On this page