‪TYPO3CMS  10.4
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

array resolvePage (array &$linkDetails, array &$configuration, bool $disableGroupAccessCheck)
 
SiteLanguage getSiteLanguageOfTargetPage (Site $siteOfTargetPage, string $targetLanguageId)
 
UriInterface generateUrlForPageWithSiteConfiguration (array $page, Site $siteOfTargetPage, array $queryParameters, string $fragment, array $conf)
 
string getClosestMountPointValueForPage ($pageId)
 
array initializeMountPointMap (string $defaultMountPoints='', string $mapRootPointList='')
 
 populateMountPointMapForPageRecursively (array &$mountPointMap, int $id, $MP_array=[], $level=0)
 
SiteInterface null getCurrentSite ()
 
SiteLanguage null getCurrentSiteLanguage ()
 
PageRepository buildPageRepository ()
 

Additional Inherited Members

Detailed Description

Builds a TypoLink to a certain page

Definition at line 46 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)
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 an array with three parts (URL, Link Text, Target)

Exceptions
UnableToLinkException

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

Definition at line 52 of file PageLinkBuilder.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Context\LanguageAspectFactory\createFromSiteLanguage(), TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_LINK, TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_SHORTCUT, TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\forceAbsoluteUrl(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\generateUrlForPageWithSiteConfiguration(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getClosestMountPointValueForPage(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSite(), TYPO3\CMS\Core\Site\Entity\Site\getRootPageId(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getSiteLanguageOfTargetPage(), TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController(), TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\parseFallbackLinkTextIfLinkTextIsEmpty(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolvePage(), TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\resolveTargetAttribute(), and TYPO3\CMS\Core\Domain\Repository\PageRepository\SHORTCUT_MODE_NONE.

◆ buildPageRepository()

PageRepository TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::buildPageRepository ( )
protected

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

Returns
‪PageRepository

Definition at line 695 of file PageLinkBuilder.php.

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

◆ 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 (   $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 452 of file PageLinkBuilder.php.

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

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

◆ getCurrentSite()

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

Check if we have a site object in the current request. if null, this usually means that this class was called from CLI context.

Returns
‪SiteInterface|null

Definition at line 658 of file PageLinkBuilder.php.

References $finder, $GLOBALS, and TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

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

◆ 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 681 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 508 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 348 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSite(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSiteLanguage(), and TYPO3\CMS\Core\Site\Entity\Site\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 531 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().

◆ populateMountPointMapForPageRecursively()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::populateMountPointMapForPageRecursively ( array &  $mountPointMap,
int  $id,
  $MP_array = [],
  $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 576 of file PageLinkBuilder.php.

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

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 it 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 305 of file PageLinkBuilder.php.

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

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