‪TYPO3CMS  10.4
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)
 
array null matchRedirect (string $domain, string $path, string $query='')
 
UriInterface null getTargetUrl (array $matchedRedirect, array $queryParams, FrontendUserAuthentication $frontendUserAuthentication, UriInterface $uri, ?SiteInterface $site=null)
 

Protected Member Functions

bool isRedirectActive (array $redirectRecord)
 
array fetchRedirects ()
 
array resolveLinkDetailsFromLinkTarget (string $redirectTarget)
 
Uri addQueryParams (array $queryParams, Uri $url)
 
UriInterface null getUriFromCustomLinkDetails (array $redirectRecord, FrontendUserAuthentication $frontendUserAuthentication, ?SiteInterface $site, array $linkDetails, array $queryParams)
 
TypoScriptFrontendController bootFrontendController (FrontendUserAuthentication $frontendUserAuthentication, ?SiteInterface $site, array $queryParams)
 
array replaceRegExpCaptureGroup (array $matchedRedirect, UriInterface $uri, array $linkDetails)
 

Protected Attributes

RedirectCacheService $redirectCacheService
 
LinkService $linkService
 
SiteFinder $siteFinder
 

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

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ addQueryParams()

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

Adds query parameters to a Uri object

Parameters
array$queryParams
Uri$url
Returns
‪Uri

Definition at line 276 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()

TypoScriptFrontendController TYPO3\CMS\Redirects\Service\RedirectService::bootFrontendController ( FrontendUserAuthentication  $frontendUserAuthentication,
?SiteInterface  $site,
array  $queryParams 
)
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.

Parameters
FrontendUserAuthentication$frontendUserAuthentication
SiteInterface | null$site
array$queryParams
Returns
‪TypoScriptFrontendController

Definition at line 356 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().

◆ fetchRedirects()

array TYPO3\CMS\Redirects\Service\RedirectService::fetchRedirects ( )
protected

Fetches all redirects from the DB and caches them, grouped by the domain does NOT take starttime/endtime into account, as it is cached.

Returns
‪array

Definition at line 170 of file RedirectService.php.

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

◆ getTargetUrl()

UriInterface null TYPO3\CMS\Redirects\Service\RedirectService::getTargetUrl ( array  $matchedRedirect,
array  $queryParams,
FrontendUserAuthentication  $frontendUserAuthentication,
UriInterface  $uri,
?SiteInterface  $site = null 
)

◆ getUriFromCustomLinkDetails()

UriInterface null TYPO3\CMS\Redirects\Service\RedirectService::getUriFromCustomLinkDetails ( array  $redirectRecord,
FrontendUserAuthentication  $frontendUserAuthentication,
?SiteInterface  $site,
array  $linkDetails,
array  $queryParams 
)
protected

Called when TypoScript/TSFE is available, so typolink is used to generate the URL

Parameters
array$redirectRecord
FrontendUserAuthentication$frontendUserAuthentication
SiteInterface | null$site
array$linkDetails
array$queryParams
Returns
‪UriInterface|null

Definition at line 302 of file RedirectService.php.

References $GLOBALS, TYPO3\CMS\Redirects\Service\RedirectService\bootFrontendController(), and TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString().

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

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

References $GLOBALS.

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

◆ matchRedirect()

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

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

Parameters
string$domain
string$path
string$query
Returns
‪array|null

Definition at line 78 of file RedirectService.php.

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

◆ replaceRegExpCaptureGroup()

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

Definition at line 387 of file RedirectService.php.

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

◆ 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 182 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().

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