RedirectService
Creates a proper URL to redirect from a matched redirect of a request
due to some possible refactorings
Table of Contents
Methods
- __construct() : mixed
- getTargetUrl() : UriInterface|null
- matchRedirect() : array<string|int, mixed>|null
- Checks against all available redirects "flat" or "regexp", and against starttime/endtime
- addQueryParams() : Uri
- Adds query parameters to a Uri object
- bootFrontendController() : TypoScriptFrontendController
- Finishing booting up TSFE, after that the following properties are available.
- fetchRedirects() : array<string|int, mixed>
- Fetches all redirects from cache, with fallback to rebuild cache from the DB if caches was empty, grouped by the domain does NOT take starttime/endtime into account, as it is cached.
- getFirstActiveRedirectFromPossibleRedirects() : array<string|int, mixed>|null
- Checks all possible redirects and return the first possible and active redirect if available.
- getUriFromCustomLinkDetails() : UriInterface|null
- Called when TypoScript/TSFE is available, so typolink is used to generate the URL
- isRedirectActive() : bool
- Check if a redirect record matches the starttime and endtime and disable restrictions
- replaceRegExpCaptureGroup() : array<string|int, mixed>
- resolveLinkDetailsFromLinkTarget() : array<string|int, mixed>
- Check if the current request is actually a redirect, and then process the redirect.
- resolveSite() : SiteInterface|null
- If no site is given, try to find a valid site for the target page
Methods
__construct()
public
__construct(RedirectCacheService $redirectCacheService, LinkService $linkService, SiteFinder $siteFinder, EventDispatcherInterface $eventDispatcher, PageInformationFactory $pageInformationFactory, FrontendTypoScriptFactory $frontendTypoScriptFactory, PhpFrontend $typoScriptCache, LoggerInterface $logger) : mixed
Parameters
- $redirectCacheService : RedirectCacheService
- $linkService : LinkService
- $siteFinder : SiteFinder
- $eventDispatcher : EventDispatcherInterface
- $pageInformationFactory : PageInformationFactory
- $frontendTypoScriptFactory : FrontendTypoScriptFactory
- $typoScriptCache : PhpFrontend
- $logger : LoggerInterface
getTargetUrl()
public
getTargetUrl(array<string|int, mixed> $matchedRedirect, ServerRequestInterface $request) : UriInterface|null
Parameters
- $matchedRedirect : array<string|int, mixed>
- $request : ServerRequestInterface
Return values
UriInterface|nullmatchRedirect()
Checks against all available redirects "flat" or "regexp", and against starttime/endtime
public
matchRedirect(string $domain, string $path[, string $query = '' ]) : array<string|int, mixed>|null
Parameters
- $domain : string
- $path : string
- $query : string = ''
Return values
array<string|int, mixed>|nulladdQueryParams()
Adds query parameters to a Uri object
protected
addQueryParams(array<string|int, mixed> $queryParams, Uri $url) : Uri
Parameters
- $queryParams : array<string|int, mixed>
- $url : Uri
Return values
UribootFrontendController()
Finishing booting up TSFE, after that the following properties are available.
protected
bootFrontendController(SiteInterface $site, array<string|int, mixed> $queryParams, ServerRequestInterface $originalRequest) : TypoScriptFrontendController
Instantiating is done by the middleware stack (see Configuration/RequestMiddlewares.php)
- TSFE->sys_page
- TSFE->config
- TSFE->cObj
So a link to a page can be generated.
Parameters
- $site : SiteInterface
- $queryParams : array<string|int, mixed>
- $originalRequest : ServerRequestInterface
Tags
Return values
TypoScriptFrontendControllerfetchRedirects()
Fetches all redirects from cache, with fallback to rebuild cache from the DB if caches was empty, grouped by the domain does NOT take starttime/endtime into account, as it is cached.
protected
fetchRedirects(string $sourceHost) : array<string|int, mixed>
Parameters
- $sourceHost : string
Return values
array<string|int, mixed>getFirstActiveRedirectFromPossibleRedirects()
Checks all possible redirects and return the first possible and active redirect if available.
protected
getFirstActiveRedirectFromPossibleRedirects(array<string|int, mixed> $possibleRedirects) : array<string|int, mixed>|null
Parameters
- $possibleRedirects : array<string|int, mixed>
Return values
array<string|int, mixed>|nullgetUriFromCustomLinkDetails()
Called when TypoScript/TSFE is available, so typolink is used to generate the URL
protected
getUriFromCustomLinkDetails(array<string|int, mixed> $redirectRecord, SiteInterface|null $site, array<string|int, mixed> $linkDetails, array<string|int, mixed> $queryParams, ServerRequestInterface $originalRequest) : UriInterface|null
Parameters
- $redirectRecord : array<string|int, mixed>
- $site : SiteInterface|null
- $linkDetails : array<string|int, mixed>
- $queryParams : array<string|int, mixed>
- $originalRequest : ServerRequestInterface
Return values
UriInterface|nullisRedirectActive()
Check if a redirect record matches the starttime and endtime and disable restrictions
protected
isRedirectActive(array<string|int, mixed> $redirectRecord) : bool
Parameters
- $redirectRecord : array<string|int, mixed>
Return values
bool —whether the redirect is active and should be used for redirecting the current request
replaceRegExpCaptureGroup()
protected
replaceRegExpCaptureGroup(array<string|int, mixed> $matchedRedirect, UriInterface $uri, array<string|int, mixed> $linkDetails) : array<string|int, mixed>
Parameters
- $matchedRedirect : array<string|int, mixed>
- $uri : UriInterface
- $linkDetails : array<string|int, mixed>
Return values
array<string|int, mixed>resolveLinkDetailsFromLinkTarget()
Check if the current request is actually a redirect, and then process the redirect.
protected
resolveLinkDetailsFromLinkTarget(string $redirectTarget) : array<string|int, mixed>
Parameters
- $redirectTarget : string
Return values
array<string|int, mixed> —the link details from the linkService
resolveSite()
If no site is given, try to find a valid site for the target page
protected
resolveSite(array<string|int, mixed> $linkDetails, SiteInterface|null $site) : SiteInterface|null
Parameters
- $linkDetails : array<string|int, mixed>
- $site : SiteInterface|null