‪TYPO3CMS  ‪main
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)
 
 getMountPointParameterFromRootPointMaps (int $pageId)
 

Protected Member Functions

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

Additional Inherited Members

Detailed Description

Builds a TypoLink to a certain page

Definition at line 54 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
Exceptions
UnableToLinkException

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

Definition at line 56 of file PageLinkBuilder.php.

References TYPO3\CMS\Webhooks\Message\$url, 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\Core\Domain\Page\getPageId(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getSiteLanguageOfTargetPage(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\modifyUrlForAccessRestrictedPage(), TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder\parseFallbackLinkTextIfLinkTextIsEmpty(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolvePage(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\resolveShortcutPage(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\shouldModifyUrlForAccessRestrictedPage(), 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 848 of file PageLinkBuilder.php.

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

◆ calculateGlobalQueryParameters()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::calculateGlobalQueryParameters ( )
protected

Get "global" query parameters that should be added. Depends on given request query parameters plus config.linkVars TypoScript setting plus eventually special arguments for logged in Backend users.

Definition at line 305 of file PageLinkBuilder.php.

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

◆ calculateMountPointParameters()

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

Calculates a possible "&MP=" GET parameter for this link when using mount points.

Definition at line 323 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getClosestMountPointValueForPage(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSite().

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

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

References TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\calculateGlobalQueryParameters(), and TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getQueryArguments().

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

◆ calculateTargetAttribute()

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

Returns the final "target" attribute for a link.

Definition at line 363 of file PageLinkBuilder.php.

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

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

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

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

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

◆ generateUrlForPageWithSiteConfiguration()

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

References $GLOBALS.

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

◆ getCurrentSite()

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.

Todo:
‪: We may want to see if we can't require a site object to be always set and fail here otherwise!

Definition at line 829 of file PageLinkBuilder.php.

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

◆ getCurrentSiteLanguage()

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.

Definition at line 838 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\getCurrentSite().

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

◆ getMountPointParameterFromRootPointMaps()

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.

Parameters
int$pageIdPage id to return MPvar value for.

Definition at line 647 of file PageLinkBuilder.php.

References TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\initializeMountPointMap().

◆ getQueryArguments()

string TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::getQueryArguments ( bool|string|int  $queryInformation,
array  $configuration 
)
protected

Gets the query arguments and assembles them for URLs. By default, only the resolved query arguments from the route are used, using "untrusted" as $queryInformation allows to also include ANY query parameter - use with care.

Arguments may be removed or set, depending on configuration.

Parameters
bool | string | int$queryInformation‪is set to "1", "true", "0", "false" or "untrusted"
array$configuration‪Configuration
Returns
‪string The URL query part (starting with a &) or empty

Definition at line 797 of file PageLinkBuilder.php.

References TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

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

◆ getSiteLanguageOfTargetPage()

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

◆ initializeMountPointMap()

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

Definition at line 668 of file PageLinkBuilder.php.

References 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 
)
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.

See also
shouldModifyUrlForAccessRestrictedPage

Definition at line 399 of file PageLinkBuilder.php.

References TYPO3\CMS\Webhooks\Message\$url.

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.

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

References TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_BE_USER_SECTION, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

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

◆ resolvePage()

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).

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

◆ shouldModifyUrlForAccessRestrictedPage()

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder::shouldModifyUrlForAccessRestrictedPage ( array  $conf,
array  $page 
)
protected

Checks if config.typolinkLinkAccessRestrictedPages is set to a specific page target, and the current link configuration typolink.linkAccessRestrictedPages is not set (= which would directly link to page that is access restricted).

Only happens if the target is access restricted.

See also
modifyUrlForAccessRestrictedPage

Definition at line 384 of file PageLinkBuilder.php.

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