‪TYPO3CMS  ‪main
TYPO3\CMS\Frontend\Typolink\LinkFactory Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\Typolink\LinkFactory:

Public Member Functions

 __construct (protected readonly LinkService $linkService, protected readonly EventDispatcherInterface $eventDispatcher, protected readonly TypoLinkCodecService $typoLinkCodecService, protected readonly FrontendInterface $runtimeCache, protected readonly SiteFinder $siteFinder,)
 
 create (string $linkText, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer)
 
 createUri (string $urlParameter, ContentObjectRenderer $contentObjectRenderer=null)
 

Protected Member Functions

 buildLinkResult (string $linkText, array $linkDetails, string $target, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer)
 
 resolveLinkDetails (string $linkParameter, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer)
 
 resolveTypolinkParameterString (string $mixedLinkParameter, array &$linkConfiguration=[])
 
 addJavaScriptOpenWindowInformationAttributes (LinkResultInterface $linkResult, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer)
 
 addAdditionalAnchorTagAttributes (LinkResultInterface $linkResult, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer)
 
 addSecurityRelValues (LinkResultInterface $linkResult)
 
 isInternalUrl (string $url)
 

Detailed Description

Main class for generating any kind of frontend links. Contains all logic for the infamous typolink() functionality.

Definition at line 39 of file LinkFactory.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Frontend\Typolink\LinkFactory::__construct ( protected readonly LinkService  $linkService,
protected readonly EventDispatcherInterface  $eventDispatcher,
protected readonly TypoLinkCodecService  $typoLinkCodecService,
protected readonly FrontendInterface  $runtimeCache,
protected readonly SiteFinder  $siteFinder 
)

Definition at line 44 of file LinkFactory.php.

Member Function Documentation

◆ addAdditionalAnchorTagAttributes()

TYPO3\CMS\Frontend\Typolink\LinkFactory::addAdditionalAnchorTagAttributes ( LinkResultInterface  $linkResult,
array  $linkConfiguration,
ContentObjectRenderer  $contentObjectRenderer 
)
protected

An abstraction method to add parameters to an A tag. Uses the ATagParams property, also includes the global TypoScript config.ATagParams

Definition at line 262 of file LinkFactory.php.

References TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\getRequest(), TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\stdWrapValue(), and TYPO3\CMS\Frontend\Typolink\LinkResultInterface\withAttributes().

Referenced by TYPO3\CMS\Frontend\Typolink\LinkFactory\create().

◆ addJavaScriptOpenWindowInformationAttributes()

◆ addSecurityRelValues()

◆ buildLinkResult()

TYPO3\CMS\Frontend\Typolink\LinkFactory::buildLinkResult ( string  $linkText,
array  $linkDetails,
string  $target,
array  $linkConfiguration,
ContentObjectRenderer  $contentObjectRenderer 
)
protected

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

Definition at line 128 of file LinkFactory.php.

References $GLOBALS, TYPO3\CMS\Frontend\Typolink\UnableToLinkException\getLinkText(), and TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\getTypoScriptFrontendController().

Referenced by TYPO3\CMS\Frontend\Typolink\LinkFactory\create().

◆ create()

◆ createUri()

TYPO3\CMS\Frontend\Typolink\LinkFactory::createUri ( string  $urlParameter,
ContentObjectRenderer  $contentObjectRenderer = null 
)

Creates a link result for a given URL (usually something like "19 _blank css-class "testtitle with whitespace" &X=y"). Helpful if you want to create any kind of URL (also possible in TYPO3 Backend).

Definition at line 114 of file LinkFactory.php.

References $GLOBALS, and TYPO3\CMS\Frontend\Typolink\LinkFactory\create().

◆ isInternalUrl()

TYPO3\CMS\Frontend\Typolink\LinkFactory::isInternalUrl ( string  $url)
protected

Checks whether the given url is an internal url.

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

Definition at line 306 of file LinkFactory.php.

References TYPO3\CMS\Webhooks\Message\$url, and TYPO3\CMS\Core\Utility\GeneralUtility\isOnCurrentHost().

Referenced by TYPO3\CMS\Frontend\Typolink\LinkFactory\addSecurityRelValues().

◆ resolveLinkDetails()

TYPO3\CMS\Frontend\Typolink\LinkFactory::resolveLinkDetails ( string  $linkParameter,
array  $linkConfiguration,
ContentObjectRenderer  $contentObjectRenderer 
)
protected

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

Definition at line 166 of file LinkFactory.php.

References TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\stdWrapValue(), and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_INPAGE.

Referenced by TYPO3\CMS\Frontend\Typolink\LinkFactory\create().

◆ resolveTypolinkParameterString()

TYPO3\CMS\Frontend\Typolink\LinkFactory::resolveTypolinkParameterString ( string  $mixedLinkParameter,
array &  $linkConfiguration = [] 
)
protected

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

Parameters
string$mixedLinkParameter‪destination data like "15,13 _blank myclass &more=1" used to create the link
array$linkConfiguration‪TypoScript configuration

Definition at line 201 of file LinkFactory.php.

Referenced by TYPO3\CMS\Frontend\Typolink\LinkFactory\create().