‪TYPO3CMS  11.5
TYPO3\CMS\Frontend\Typolink\PageLinkBuilder Class Reference
Inheritance diagram for TYPO3\CMS\Frontend\Typolink\PageLinkBuilder:
TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder

Public Member Functions

 build (array &$linkDetails, string $linkText, string $target, array $conf)
 
string getMountPointParameterFromRootPointMaps (int $pageId)
 

Protected Member Functions

 calculateUrlFragment (array $conf, array $linkDetails)
 
 calculateQueryParameters (array &$conf, array $linkDetails)
 
 calculateMountPointParameters (array &$page, bool $disableGroupAccessCheck, string $linkText)
 
 calculateTargetAttribute (array $page, array $conf, bool $treatAsExternalLink, string $target)
 
 modifyUrlForAccessRestrictedPage (string $url, array $page, string $overridePageType, array $conf)
 
array resolvePage (array &$linkDetails, array &$configuration, bool $disableGroupAccessCheck)
 
 resolveShortcutPage (array $page, PageRepository $pageRepository, bool $disableGroupAccessCheck)
 
SiteLanguage getSiteLanguageOfTargetPage (Site $siteOfTargetPage, string $targetLanguageId)
 
UriInterface generateUrlForPageWithSiteConfiguration (array $page, Site $siteOfTargetPage, array $queryParameters, string $fragment, array $conf)
 
string getClosestMountPointValueForPage (int $pageId)
 
array initializeMountPointMap (string $defaultMountPoints='', string $mapRootPointList='')
 
 populateMountPointMapForPageRecursively (array &$mountPointMap, int $id, array $MP_array=[], int $level=0)
 
SiteInterface null getCurrentSite ()
 
SiteLanguage null getCurrentSiteLanguage ()
 
 buildPageRepository (LanguageAspect $languageAspect=null)
 

Additional Inherited Members

Detailed Description

Builds a TypoLink to a certain page

Definition at line 51 of file PageLinkBuilder.php.

Member Function Documentation

◆ build()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::build ( array &  $linkDetails,
string  $linkText,
string  $target,
array  $conf 
)

‪Should be implemented by all subclasses to return an array with three parts:

  • ‪URL
  • ‪Link Text (can be modified)
  • ‪Target (can be modified)
  • ‪Tag Attributes (optional)
Parameters
array$linkDetails‪parsed link details by the LinkService
string$linkText‪the link text
string$target‪the target to point to
array$conf‪the TypoLink configuration array
Returns
‪array|LinkResultInterface an array with three parts (URL, Link Text, Target) - please note that in TYPO3 v12.0. this method will require to return a LinkResultInterface object

Exceptions
UnableToLinkException

Reimplemented from TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder.

Definition at line 57 of file PageLinkBuilder.php.

References $GLOBALS, TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\buildPageRepository(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\calculateMountPointParameters(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\calculateQueryParameters(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\calculateTargetAttribute(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\calculateUrlFragment(), TYPO3\CMS\Core\Context\LanguageAspectFactory\createFromSiteLanguage(), TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_LINK, TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\generateUrlForPageWithSiteConfiguration(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSite(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getSiteLanguageOfTargetPage(), TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\modifyUrlForAccessRestrictedPage(), TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\parseFallbackLinkTextIfLinkTextIsEmpty(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolvePage(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolveShortcutPage(), and TYPO3\CMS\Core\LinkHandling\LinkService\TYPE_PAGE.

◆ buildPageRepository()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::buildPageRepository ( LanguageAspect  $languageAspect = null)
protected

Builds PageRepository instance without depending on global context, e.g. not automatically overlaying records based on current request language.

Definition at line 772 of file PageLinkBuilder.php.

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\build(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolvePage().

◆ calculateMountPointParameters()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::calculateMountPointParameters ( array &  $page,
bool  $disableGroupAccessCheck,
string  $linkText 
)
protected

◆ calculateQueryParameters()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::calculateQueryParameters ( array &  $conf,
array  $linkDetails 
)
protected

Takes all given options into account to calculate the additional GET parameters for the link, and returns them as a clean array without duplicates.

  • ‪addQueryString
  • ‪additionalParams (+ the ones added from "parameter")
  • ‪config.linkVars
  • ‪type (from "parameter")
  • ‪no_cache

This also does a transformation to remove "L" and "_language" arguments and put this into the $conf array.

Mount Points are added later-on.

Definition at line 223 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\build().

◆ calculateTargetAttribute()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::calculateTargetAttribute ( array  $page,
array  $conf,
bool  $treatAsExternalLink,
string  $target 
)
protected

◆ calculateUrlFragment()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::calculateUrlFragment ( array  $conf,
array  $linkDetails 
)
protected

Checks for the stdWrap "section" which returns the fragment for the generated URL.

Detail: When using a section as an integer, a "c" is added, which referes to a tt_content element. see https://forge.typo3.org/issues/19832 for further work on this limitation.

Definition at line 203 of file PageLinkBuilder.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\build().

◆ generateUrlForPageWithSiteConfiguration()

UriInterface TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::generateUrlForPageWithSiteConfiguration ( array  $page,
Site  $siteOfTargetPage,
array  $queryParameters,
string  $fragment,
array  $conf 
)
protected

◆ getClosestMountPointValueForPage()

string TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::getClosestMountPointValueForPage ( int  $pageId)
protected

The function will do its best to find a MP value that will keep the page id inside the current Mount Point rootline if any.

Parameters
int$pageId‪page id
Returns
‪string MP value, prefixed with &MP= (depending on $raw)

Definition at line 525 of file PageLinkBuilder.php.

References $GLOBALS, and TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\calculateMountPointParameters().

◆ getCurrentSite()

SiteInterface null TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::getCurrentSite ( )
protected

◆ getCurrentSiteLanguage()

SiteLanguage null TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::getCurrentSiteLanguage ( )
protected

If the current request has a site language, this means that the SiteResolver has detected a page with a site configuration and a selected language, so let's choose that one.

Returns
‪SiteLanguage|null

Definition at line 757 of file PageLinkBuilder.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\generateUrlForPageWithSiteConfiguration(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getSiteLanguageOfTargetPage().

◆ getMountPointParameterFromRootPointMaps()

string TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::getMountPointParameterFromRootPointMaps ( int  $pageId)

Initializes the automatically created mountPointMap coming from the "config.MP_mapRootPoints" setting Can be called many times with overhead only the first time since then the map is generated and cached in memory.

Previously located within TemplateService::getFromMPmap()

Parameters
int$pageIdPage id to return MPvar value for.
Returns
‪string

Definition at line 581 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\initializeMountPointMap().

◆ getSiteLanguageOfTargetPage()

SiteLanguage TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::getSiteLanguageOfTargetPage ( Site  $siteOfTargetPage,
string  $targetLanguageId 
)
protected

Fetches the requested language of a site that the link should be built for

Parameters
Site$siteOfTargetPage
string$targetLanguageId‪"current" or the languageId
Returns
‪SiteLanguage
Exceptions
UnableToLinkException

Definition at line 423 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSite(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSiteLanguage(), and TYPO3\CMS\Core\Site\Entity\SiteInterface\getLanguageById().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\build(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\generateUrlForPageWithSiteConfiguration().

◆ initializeMountPointMap()

array TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::initializeMountPointMap ( string  $defaultMountPoints = '',
string  $mapRootPointList = '' 
)
protected

Create mount point map, based on TypoScript config.MP_mapRootPoints and config.MP_defaults.

Parameters
string$defaultMountPoints‪a string as defined in config.MP_defaults
string$mapRootPointList‪a string as defined in config.MP_mapRootPoints
Returns
‪array

Definition at line 604 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController(), TYPO3\CMS\Core\Utility\GeneralUtility\intExplode(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\populateMountPointMapForPageRecursively(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getMountPointParameterFromRootPointMaps().

◆ modifyUrlForAccessRestrictedPage()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::modifyUrlForAccessRestrictedPage ( string  $url,
array  $page,
string  $overridePageType,
array  $conf 
)
protected

If the target page is access restricted, and globally configured to be linked to a different page (e.g. login page) via config.typolinkLinkAccessRestrictedPages = 123 then the URL is modified.

Definition at line 329 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\build().

◆ populateMountPointMapForPageRecursively()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::populateMountPointMapForPageRecursively ( array &  $mountPointMap,
int  $id,
array  $MP_array = [],
int  $level = 0 
)
protected

Creating mountPointMap for a certain ID root point. Previously called TemplateService->initMPmap_create()

Parameters
array$mountPointMap‪the exiting mount point map
int$id‪Root id from which to start map creation.
array$MP_array‪MP_array passed from root page.
int$level‪Recursion brake. Incremented for each recursive call. 20 is the limit.
See also
getMountPointParameterFromRootPointMaps()

Definition at line 649 of file PageLinkBuilder.php.

References TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_BE_USER_SECTION, TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_RECYCLER, TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\initializeMountPointMap().

◆ resolvePage()

array TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::resolvePage ( array &  $linkDetails,
array &  $configuration,
bool  $disableGroupAccessCheck 
)
protected

Resolves page and if a translated page was found, resolves that to its language parent, adjusts ‘$linkDetails['pageuid’](for hook processing) and modifies$configuration['language']` (for language URL generation).

Parameters
array$linkDetails
array$configuration
bool$disableGroupAccessCheck
Returns
‪array

Definition at line 364 of file PageLinkBuilder.php.

References $GLOBALS, TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\buildPageRepository(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolveShortcutPage().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\build().

◆ resolveShortcutPage()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::resolveShortcutPage ( array  $page,
PageRepository  $pageRepository,
bool  $disableGroupAccessCheck 
)
protected

Checks if page is a shortcut, then resolves the target page directly

Definition at line 405 of file PageLinkBuilder.php.

References TYPO3\CMS\Core\Domain\Repository\PageRepository\resolveShortcutPage().

Referenced by TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\build(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolvePage().