LinkFactory

class \TYPO3\CMS\Frontend\Typolink\LinkFactory

Implements
LoggerAwareInterface
Uses
DefaultJavaScriptAssetTrait, LoggerAwareTrait

Main class for generating any kind of frontend links.

Contains all logic for the infamous typolink() functionality.

Table of Contents

Interfaces

LoggerAwareInterface

Properties

$defaultFrontendJavaScriptFile  : string
$eventDispatcher  : EventDispatcherInterface
$linkService  : LinkService
$runtimeCache  : FrontendInterface
$siteFinder  : SiteFinder
$typoLinkCodecService  : TypoLinkCodecService

Methods

__construct()  : mixed
create()  : LinkResultInterface
Main method to create links from typolink strings and configuration.
createFromUriString()  : LinkResultInterface
Legacy method, use createUri() instead.
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

$defaultFrontendJavaScriptFile

protected string $defaultFrontendJavaScriptFile = 'EXT:frontend/Resources/Public/JavaScript/default_frontend.js'

$eventDispatcher read-only

protected EventDispatcherInterface $eventDispatcher

Methods

createFromUriString()

Legacy method, use createUri() instead.

public createFromUriString(string $urlParameter) : LinkResultInterface

Deprecated

will be removed in TYPO3 v13.0.

Parameters

$urlParameter : string

Return values

LinkResultInterface

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() : void

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) : bool

It will check the host part only, against all configured sites whether the given host is any. If so, the url is considered internal.

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 to move away from GeneralUtility::isOnCurrentHost

Parameters

$url : string

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() : bool

Return values

bool

shallRemoveDefaultFrontendJavaScript()

protected shallRemoveDefaultFrontendJavaScript() : bool

Return values

bool
On this page