‪TYPO3CMS  ‪main
TYPO3\CMS\Redirects\Service\RedirectService Class Reference
Inheritance diagram for TYPO3\CMS\Redirects\Service\RedirectService:

Public Member Functions

 __construct (private readonly RedirectCacheService $redirectCacheService, private readonly LinkService $linkService, private readonly SiteFinder $siteFinder, private readonly EventDispatcherInterface $eventDispatcher, private readonly PageInformationFactory $pageInformationFactory,)
 matchRedirect (string $domain, string $path, string $query='')
 getTargetUrl (array $matchedRedirect, ServerRequestInterface $request)

Protected Member Functions

bool isRedirectActive (array $redirectRecord)
 fetchRedirects (string $sourceHost)
array resolveLinkDetailsFromLinkTarget (string $redirectTarget)
 resolveSite (array $linkDetails, ?SiteInterface $site)
 addQueryParams (array $queryParams, Uri $url)
 getUriFromCustomLinkDetails (array $redirectRecord, ?SiteInterface $site, array $linkDetails, array $queryParams, ServerRequestInterface $originalRequest)
 bootFrontendController (SiteInterface $site, array $queryParams, ServerRequestInterface $originalRequest)
 replaceRegExpCaptureGroup (array $matchedRedirect, UriInterface $uri, array $linkDetails)
 getFirstActiveRedirectFromPossibleRedirects (array $possibleRedirects)

Private Member Functions

 cleanupTSFE ()

Detailed Description

Creates a proper URL to redirect from a matched redirect of a request

due to some possible refactorings in TYPO3 v9

Definition at line 52 of file RedirectService.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Redirects\Service\RedirectService::__construct ( private readonly RedirectCacheService  $redirectCacheService,
private readonly LinkService  $linkService,
private readonly SiteFinder  $siteFinder,
private readonly EventDispatcherInterface  $eventDispatcher,
private readonly PageInformationFactory  $pageInformationFactory 

Definition at line 56 of file RedirectService.php.

Member Function Documentation

◆ addQueryParams()

TYPO3\CMS\Redirects\Service\RedirectService::addQueryParams ( array  $queryParams,
Uri  $url 

Adds query parameters to a Uri object

Definition at line 315 of file RedirectService.php.

References TYPO3\CMS\Webhooks\Message\$url.

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\getTargetUrl().

◆ bootFrontendController()

TYPO3\CMS\Redirects\Service\RedirectService::bootFrontendController ( SiteInterface  $site,
array  $queryParams,
ServerRequestInterface  $originalRequest 

Finishing booting up TSFE, after that the following properties are available.

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.

‪: This messes quite a bit with dependencies here. RedirectService is called by an early middleware before TSFE has been set up at all. The code thus has to hop through various loops later middlewares would usually do. The overall scenario of needing a partially set up TSFE for target redirect calculation is quite unfortunate here and should be sorted out differently by further refactoring the link building and reducing TSFE dependencies.

Definition at line 390 of file RedirectService.php.

References $GLOBALS, and TYPO3\CMS\Core\Site\Entity\SiteInterface\getRootPageId().

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\getUriFromCustomLinkDetails().

◆ cleanupTSFE()

TYPO3\CMS\Redirects\Service\RedirectService::cleanupTSFE ( )
‪: Needs to vanish. The existence of this method is a side-effect of the technical debt that a TSFE has to be set up for link generation, see the comment on bootFrontendController() for more details.

Definition at line 461 of file RedirectService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\getUriFromCustomLinkDetails().

◆ fetchRedirects()

TYPO3\CMS\Redirects\Service\RedirectService::fetchRedirects ( string  $sourceHost)

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.

Definition at line 193 of file RedirectService.php.

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\matchRedirect().

◆ getFirstActiveRedirectFromPossibleRedirects()

TYPO3\CMS\Redirects\Service\RedirectService::getFirstActiveRedirectFromPossibleRedirects ( array  $possibleRedirects)

Checks all possible redirects and return the first possible and active redirect if available.

Definition at line 445 of file RedirectService.php.

References TYPO3\CMS\Redirects\Service\RedirectService\isRedirectActive().

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\matchRedirect().

◆ getTargetUrl()

◆ getUriFromCustomLinkDetails()

TYPO3\CMS\Redirects\Service\RedirectService::getUriFromCustomLinkDetails ( array  $redirectRecord,
?SiteInterface  $site,
array  $linkDetails,
array  $queryParams,
ServerRequestInterface  $originalRequest 

◆ isRedirectActive()

bool TYPO3\CMS\Redirects\Service\RedirectService::isRedirectActive ( array  $redirectRecord)

Check if a redirect record matches the starttime and endtime and disable restrictions

‪bool whether the redirect is active and should be used for redirecting the current request

Definition at line 183 of file RedirectService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\getFirstActiveRedirectFromPossibleRedirects().

◆ matchRedirect()

TYPO3\CMS\Redirects\Service\RedirectService::matchRedirect ( string  $domain,
string  $path,
string  $query = '' 

◆ replaceRegExpCaptureGroup()

TYPO3\CMS\Redirects\Service\RedirectService::replaceRegExpCaptureGroup ( array  $matchedRedirect,
UriInterface  $uri,
array  $linkDetails 

◆ resolveLinkDetailsFromLinkTarget()

array TYPO3\CMS\Redirects\Service\RedirectService::resolveLinkDetailsFromLinkTarget ( string  $redirectTarget)

Check if the current request is actually a redirect, and then process the redirect.

‪array the link details from the linkService

Definition at line 203 of file RedirectService.php.

References TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_FILE, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_FOLDER, TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_UNKNOWN, and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_URL.

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\getTargetUrl().

◆ resolveSite()

TYPO3\CMS\Redirects\Service\RedirectService::resolveSite ( array  $linkDetails,
?SiteInterface  $site 

If no site is given, try to find a valid site for the target page

Definition at line 300 of file RedirectService.php.

References TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_PAGE.

Referenced by TYPO3\CMS\Redirects\Service\RedirectService\getTargetUrl().