LinkFactory
readonly class \
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
$linkService
protected
LinkService
$linkService
$logger
protected
LoggerInterface
$logger
$typoLinkCodecService
protected
TypoLinkCodecService
$typoLinkCodecService
Methods
__construct()
public
__construct(LinkService $linkService, EventDispatcherInterface $eventDispatcher, TypoLinkCodecService $typoLinkCodecService, LoggerInterface $logger) : mixed
Parameters
- $linkService : LinkService
- $eventDispatcher : EventDispatcherInterface
- $typoLinkCodecService : TypoLinkCodecService
- $logger : LoggerInterface
create()
Main method to create links from typolink strings and configuration.
public
create(string $linkText, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Parameters
- $linkText : string
- $linkConfiguration : array
- $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 $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Uses the ATagParams property, also includes the global TypoScript config.ATagParams
Parameters
- $linkResult : LinkResultInterface
- $linkConfiguration : array
- $contentObjectRenderer : ContentObjectRenderer
Return values
LinkResultInterfaceaddDefaultFrontendJavaScript()
protected
addDefaultFrontendJavaScript(ServerRequestInterface $request) : void
Parameters
- $request : ServerRequestInterface
addJavaScriptOpenWindowInformationAttributes()
protected
addJavaScriptOpenWindowInformationAttributes(LinkResultInterface $linkResult, array $linkConfiguration, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Parameters
- $linkResult : LinkResultInterface
- $linkConfiguration : array
- $contentObjectRenderer : ContentObjectRenderer
Return values
LinkResultInterfaceaddSecurityRelValues()
protected
addSecurityRelValues(LinkResultInterface $linkResult, ContentObjectRenderer $contentObjectRenderer) : LinkResultInterface
Parameters
- $linkResult : LinkResultInterface
- $contentObjectRenderer : ContentObjectRenderer
Return values
LinkResultInterfacebuildLinkResult()
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
LinkResultInterfaceisInternalUrl()
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
boolresolveLinkDetails()
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|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 &$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
arrayshallExportDefaultFrontendJavaScript()
protected
shallExportDefaultFrontendJavaScript(ServerRequestInterface $request) : bool
Parameters
- $request : ServerRequestInterface
Return values
boolshallRemoveDefaultFrontendJavaScript()
protected
shallRemoveDefaultFrontendJavaScript(ServerRequestInterface $request) : bool
Parameters
- $request : ServerRequestInterface