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

Public Member Functions

 __construct (RedirectCacheService $redirectCacheService, LinkService $linkService, SiteFinder $siteFinder)
 
 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)
 

Protected Attributes

RedirectCacheService $redirectCacheService
 
LinkService $linkService
 
SiteFinder $siteFinder
 

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 49 of file RedirectService.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Redirects\Service\RedirectService::__construct ( RedirectCacheService  $redirectCacheService,
LinkService  $linkService,
SiteFinder  $siteFinder 
)

Member Function Documentation

◆ addQueryParams()

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

Adds query parameters to a Uri object

Definition at line 314 of file RedirectService.php.

References TYPO3\CMS\Core\Http\Uri\getQuery(), and TYPO3\CMS\Core\Http\Uri\withQuery().

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

◆ bootFrontendController()

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

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

Instantiating is done by the middleware stack (see Configuration/RequestMiddlewares.php)

  • ‪TSFE->fe_user
  • ‪TSFE->sys_page
  • ‪TSFE->tmpl
  • ‪TSFE->config
  • ‪TSFE->cObj

So a link to a page can be generated.

Definition at line 393 of file RedirectService.php.

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

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

◆ cleanupTSFE()

TYPO3\CMS\Redirects\Service\RedirectService::cleanupTSFE ( )
private
Todo:
‪: 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 462 of file RedirectService.php.

References $GLOBALS.

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

◆ fetchRedirects()

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

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 191 of file RedirectService.php.

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

◆ getFirstActiveRedirectFromPossibleRedirects()

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

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

Definition at line 446 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 
)
protected

◆ isRedirectActive()

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

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

Parameters
array$redirectRecord
Returns
‪bool whether the redirect is active and should be used for redirecting the current request

Definition at line 181 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 = '' 
)

Checks against all available redirects "flat" or "regexp", and against starttime/endtime

Definition at line 75 of file RedirectService.php.

References TYPO3\CMS\Redirects\Service\RedirectService\fetchRedirects(), and TYPO3\CMS\Redirects\Service\RedirectService\getFirstActiveRedirectFromPossibleRedirects().

◆ replaceRegExpCaptureGroup()

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

◆ resolveLinkDetailsFromLinkTarget()

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

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

Parameters
string$redirectTarget
Returns
‪array the link details from the linkService

Definition at line 202 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 
)
protected

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

Definition at line 299 of file RedirectService.php.

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

Member Data Documentation

◆ $linkService

LinkService TYPO3\CMS\Redirects\Service\RedirectService::$linkService
protected

◆ $redirectCacheService

RedirectCacheService TYPO3\CMS\Redirects\Service\RedirectService::$redirectCacheService
protected

◆ $siteFinder

SiteFinder TYPO3\CMS\Redirects\Service\RedirectService::$siteFinder
protected