‪TYPO3CMS  9.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

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)
 
array generateUrlForPageWithoutSiteConfiguration (array $page, array $additionalQueryParams, array $conf, string $pageType, string $sectionMark, string $target, array $MPvarAcc)
 
string getClosestMountPointValueForPage ($pageId)
 
array initializeMountPointMap (string $defaultMountPoints=null, string $mapRootPointList=null)
 
 populateMountPointMapForPageRecursively (array &$mountPointMap, int $id, $MP_array=[], $level=0)
 
array createTotalUrlAndLinkData ($page, $target, $no_cache, $addParams='', $typeOverride='', $targetDomain='')
 
SiteInterface null getCurrentSite ()
 
SiteLanguage null getCurrentSiteLanguage ()
 
PageRepository buildPageRepository ()
 

Additional Inherited Members

Detailed Description

Builds a TypoLink to a certain page

Definition at line 48 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 54 of file PageLinkBuilder.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Context\LanguageAspectFactory\createFromSiteLanguage(), TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_SHORTCUT, TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\forceAbsoluteUrl(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\generateUrlForPageWithoutSiteConfiguration(), 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\Frontend\Page\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 886 of file PageLinkBuilder.php.

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

◆ createTotalUrlAndLinkData()

array TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::createTotalUrlAndLinkData (   $page,
  $target,
  $no_cache,
  $addParams = '',
  $typeOverride = '',
  $targetDomain = '' 
)
protected

The mother of all functions creating links/URLs etc in a TypoScript environment. See the references below. Basically this function takes care of issues such as type,id,alias and Mount Points, URL rewriting (through hooks), M5/B6 encoded parameters etc. It is important to pass all links created through this function since this is the guarantee that globally configured settings for link creating are observed and that your applications will conform to the various/many configuration options in TypoScript Templates regarding this.

Parameters
array$page‪The page record of the page to which we are creating a link. Needed due to fields like uid, alias, target, title and sectionIndex_uid.
string$target‪Target string
bool$no_cache‪If set, then the "&no_cache=1" parameter is included in the URL.
string$addParams‪Additional URL parameters to set in the URL. Syntax is "&foo=bar&foo2=bar2" etc. Also used internally to add parameters if needed.
string$typeOverride‪If you set this value to something else than a blank string, then the typeNumber used in the link will be forced to this value. Normally the typeNum is based on the target set OR on $this->getTypoScriptFrontendController()->config['config']['forceTypeValue'] if found.
string$targetDomain‪The target Doamin, if any was detected in typolink
Returns
‪array Contains keys like "totalURL", "url", "sectionIndex", "linkVars", "no_cache", "type" of which "totalURL" is normally the value you would use while the other keys contains various parts that was used to construct "totalURL

Definition at line 783 of file PageLinkBuilder.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString(), TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getMountPointParameterFromRootPointMaps(), and TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\getTypoScriptFrontendController().

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

◆ generateUrlForPageWithoutSiteConfiguration()

array TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::generateUrlForPageWithoutSiteConfiguration ( array  $page,
array  $additionalQueryParams,
array  $conf,
string  $pageType,
string  $sectionMark,
string  $target,
array  $MPvarAcc 
)
protected

Generate a URL for a page without site configuration

Parameters
array$page
array$additionalQueryParams
array$conf
string$pageType
string$sectionMark
string$target
array$MPvarAcc
Returns
‪array

Definition at line 463 of file PageLinkBuilder.php.

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

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 (   $pageId)
protected

Returns the &MP variable value for a page id. 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 569 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 849 of file PageLinkBuilder.php.

References $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 872 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 625 of file PageLinkBuilder.php.

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

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

◆ 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 356 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 = null,
string  $mapRootPointList = null 
)
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 | null$mapRootPointList‪a string as defined in config.MP_mapRootPoints
Returns
‪array

Definition at line 648 of file PageLinkBuilder.php.

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

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

References TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_BE_USER_SECTION, TYPO3\CMS\Frontend\Page\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 312 of file PageLinkBuilder.php.

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

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