LinkFactory implements LoggerAwareInterface uses DefaultJavaScriptAssetTrait, LoggerAwareTrait
Main class for generating any kind of frontend links.
Contains all logic for the infamous typolink() functionality.
Attributes
- #[Autoconfigure]
- $public: true
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.
- 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<string|int, mixed>|null
- Creates $linkDetails out of the link parameter so the concrete LinkBuilder can be resolved.
- resolveTypolinkParameterString() : array<string|int, mixed>
- 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
$linkService read-only
protected
LinkService
$linkService
$runtimeCache read-only
protected
FrontendInterface
$runtimeCache
Attributes
- #[Autowire]
- $service: 'cache.runtime'
$siteFinder read-only
protected
SiteFinder
$siteFinder
$typoLinkCodecService read-only
protected
TypoLinkCodecService
$typoLinkCodecService
Methods
__construct()
public
__construct(LinkService $linkService, EventDispatcherInterface $eventDispatcher, TypoLinkCodecService $typoLinkCodecService, FrontendInterface $runtimeCache, SiteFinder $siteFinder) : mixed
Parameters
- $linkService : LinkService
- $eventDispatcher : EventDispatcherInterface
- $typoLinkCodecService : TypoLinkCodecService
- $runtimeCache : FrontendInterface
- $siteFinder : SiteFinder
create()
Main method to create links from typolink strings and configuration.
public
create(string $linkText, array<string|int, mixed> $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Parameters
- $linkText : string
- $linkConfiguration : array<string|int, mixed>
- $contentObjectRenderer : ContentObjectRenderer
Tags
Return values
LinkResultInterfacecreateUri()
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
LinkResultInterfaceaddAdditionalAnchorTagAttributes()
An abstraction method to add parameters to an A tag.
protected
addAdditionalAnchorTagAttributes(LinkResultInterface $linkResult, array<string|int, mixed> $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Uses the ATagParams property, also includes the global TypoScript config.ATagParams
Parameters
- $linkResult : LinkResultInterface
- $linkConfiguration : array<string|int, mixed>
- $contentObjectRenderer : ContentObjectRenderer
Return values
LinkResultInterfaceaddDefaultFrontendJavaScript()
protected
addDefaultFrontendJavaScript(ServerRequestInterface $request) : void
Parameters
- $request : ServerRequestInterface
addJavaScriptOpenWindowInformationAttributes()
protected
addJavaScriptOpenWindowInformationAttributes(LinkResultInterface $linkResult, array<string|int, mixed> $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Parameters
- $linkResult : LinkResultInterface
- $linkConfiguration : array<string|int, mixed>
- $contentObjectRenderer : ContentObjectRenderer
Return values
LinkResultInterfaceaddSecurityRelValues()
protected
addSecurityRelValues(LinkResultInterface $linkResult) : LinkResultInterface
Parameters
- $linkResult : LinkResultInterface
Return values
LinkResultInterfacebuildLinkResult()
Dispatches the linkDetails + configuration to the concrete typolink Builder (page, email etc) and returns a LinkResultInterface.
protected
buildLinkResult(string $linkText, array<string|int, mixed> $linkDetails, string $target, array<string|int, mixed> $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Parameters
- $linkText : string
- $linkDetails : array<string|int, mixed>
- $target : string
- $linkConfiguration : array<string|int, mixed>
- $contentObjectRenderer : ContentObjectRenderer
Return values
LinkResultInterfaceisInternalUrl()
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
boolresolveLinkDetails()
Creates $linkDetails out of the link parameter so the concrete LinkBuilder can be resolved.
protected
resolveLinkDetails(string $linkParameter, array<string|int, mixed> $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : array<string|int, mixed>|null
Parameters
- $linkParameter : string
- $linkConfiguration : array<string|int, mixed>
- $contentObjectRenderer : ContentObjectRenderer
Return values
array<string|int, mixed>|nullresolveTypolinkParameterString()
Does the magic to split the full "typolink" string like "15,13 _blank myclass &more=1" into separate parts
protected
resolveTypolinkParameterString(string $mixedLinkParameter[, array<string|int, mixed> &$linkConfiguration = [] ]) : array<string|int, mixed>
Parameters
- $mixedLinkParameter : string
-
destination data like "15,13 _blank myclass &more=1" used to create the link
- $linkConfiguration : array<string|int, mixed> = []
-
TypoScript configuration
Return values
array<string|int, mixed>shallExportDefaultFrontendJavaScript()
protected
shallExportDefaultFrontendJavaScript(ServerRequestInterface $request) : bool
Parameters
- $request : ServerRequestInterface
Return values
boolshallRemoveDefaultFrontendJavaScript()
protected
shallRemoveDefaultFrontendJavaScript(ServerRequestInterface $request) : bool
Parameters
- $request : ServerRequestInterface