Skip to content

Commit

Permalink
[TASK] Move linkData() functionality in PageLinkBuilder
Browse files Browse the repository at this point in the history
The "mother of building all links in Frontend" is moved
into PageLinkBuilder. Along with this, building a
mountPointMap is moved into the PageLinkBuilder as well,
as this is solely needed.

Existing methods are deprecated:
 * TemplateService->linkData
 * TemplateService->getFromMPmap
 * TemplateService->initMPmap_create

The existing hook is moved into PageLinkBuilder as well,
so functionality like RealURL will work the same.

Resolves: #84637
Releases: master
Change-Id: I513bd721a77ed8959f3c8b4bfc4eaa25dd05eacc
Reviewed-on: https://review.typo3.org/56576
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
  • Loading branch information
bmack authored and susannemoog committed Apr 6, 2018
1 parent d12e0fc commit d68a620
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 10 deletions.
7 changes: 7 additions & 0 deletions typo3/sysext/core/Classes/TypoScript/TemplateService.php
Expand Up @@ -306,6 +306,7 @@ class TemplateService

/**
* Contains mapping of Page id numbers to MP variables.
* This is not used anymore, and will be removed in TYPO3 v10.
*
* @var string
*/
Expand Down Expand Up @@ -1478,9 +1479,11 @@ public function getRootId(): int
* @param string $targetDomain The target Doamin, if any was detected in typolink
* @return array Contains keys like "totalURL", "url", "sectionIndex", "linkVars", "no_cache", "type", "target" of which "totalURL" is normally the value you would use while the other keys contains various parts that was used to construct "totalURL
* @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typoLink(), \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::link()
* @deprecated - will be removed in TYPO3 v10.0 - have a look at PageLinkBuilder
*/
public function linkData($page, $oTarget, $no_cache, $_ = null, $overrideArray = null, $addParams = '', $typeOverride = '', $targetDomain = '')
{
trigger_error('Creating URLs to pages is now encapsulated into PageLinkBuilder, and should be used in the future. This method will be removed in TYPO3 v10.0', E_USER_DEPRECATED);
$LD = [];
// Overriding some fields in the page record and still preserves the values by adding them as parameters. Little strange function.
if (is_array($overrideArray)) {
Expand Down Expand Up @@ -1562,9 +1565,11 @@ public function linkData($page, $oTarget, $no_cache, $_ = null, $overrideArray =
* @return string
* @see initMPmap_create()
* @todo Implement some caching of the result between hits. (more than just the memory caching used here)
* @deprecated - will be removed in TYPO3 v10.
*/
public function getFromMPmap($pageId = 0)
{
trigger_error('Getting a mount point parameter for a page is now built into PageLinkBuilder, and should be used in the future. This method will be removed in TYPO3 v10.0', E_USER_DEPRECATED);
// Create map if not found already:
if (!is_array($this->MPmap)) {
$this->MPmap = [];
Expand Down Expand Up @@ -1597,9 +1602,11 @@ public function getFromMPmap($pageId = 0)
* @param array $MP_array MP_array passed from root page.
* @param int $level Recursion brake. Incremented for each recursive call. 20 is the limit.
* @see getFromMPvar()
* @deprecated will be removed in TYPO3 v10.0
*/
public function initMPmap_create($id, $MP_array = [], $level = 0)
{
trigger_error('Building a mount point parameter map is now built into PageLinkBuilder, and should be used in the future. This method will be removed in TYPO3 v10.0', E_USER_DEPRECATED);
$id = (int)$id;
if ($id <= 0) {
return;
Expand Down
@@ -0,0 +1,42 @@
.. include:: ../../Includes.txt

========================================================================================
Deprecation: #84637 - TemplateService->linkData() functionality moved in PageLinkBuilder
========================================================================================

See :issue:`84637`

Description
===========

In the process of streamlining the link generation to pages in the Frontend, the master method
:php:`TemplateService->linkData` and all functionality regarding resolving of the according Mount Point parameters
have been migrated into the TypoLink PageLinkBuilder class.

The following methods have been marked as deprecated:
* :php:`TYPO3\CMS\Core\TypoScript\TemplateService->linkData`
* :php:`TYPO3\CMS\Core\TypoScript\TemplateService->getFromMPmap`
* :php:`TYPO3\CMS\Core\TypoScript\TemplateService->initMPmap_create`


Impact
======

Calling any of the methods above will trigger a PHP deprecation message.


Affected Installations
======================

Any TYPO3 installations with third-party extensions calling the methods directly, extensions using the
existing hook :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc']`
will work the same way.


Migration
=========

Access the corresponding new methods within :php:`PageLinkBuilder` instead of the TemplateService-related
methods, or use the existing hook to modify parameters for a URL.

.. index:: FullyScanned
Expand Up @@ -26,6 +26,7 @@
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
use TYPO3\CMS\Frontend\Page\PageRepository;
use TYPO3\CMS\Frontend\Typolink\PageLinkBuilder;

/**
* Generating navigation/menus from TypoScript
Expand Down Expand Up @@ -708,14 +709,15 @@ protected function prepareMenuItemsForDirectoryMenu($specialValue, $sortingField
$specialValue = $tsfe->page['uid'];
}
$items = GeneralUtility::intExplode(',', $specialValue);
$pageLinkBuilder = GeneralUtility::makeInstance(PageLinkBuilder::class, $this->parent_cObj);
foreach ($items as $id) {
$MP = $this->tmpl->getFromMPmap($id);
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps($id);
// Checking if a page is a mount page and if so, change the ID and set the MP var properly.
$mount_info = $this->sys_page->getMountPointInfo($id);
if (is_array($mount_info)) {
if ($mount_info['overlay']) {
// Overlays should already have their full MPvars calculated:
$MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps((int)$mount_info['mount_pid']);
$MP = $MP ? $MP : $mount_info['MPvar'];
} else {
$MP = ($MP ? $MP . ',' : '') . $mount_info['MPvar'];
Expand Down Expand Up @@ -779,8 +781,9 @@ protected function prepareMenuItemsForListMenu($specialValue)
$loadDB->start($specialValue, 'pages');
$loadDB->additionalWhere['pages'] = $this->parent_cObj->enableFields('pages', false, $skippedEnableFields);
$loadDB->getFromDB();
$pageLinkBuilder = GeneralUtility::makeInstance(PageLinkBuilder::class, $this->parent_cObj);
foreach ($loadDB->itemArray as $val) {
$MP = $this->tmpl->getFromMPmap($val['id']);
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps((int)$val['id']);
// Keep mount point?
$mount_info = $this->sys_page->getMountPointInfo($val['id']);
// There is a valid mount point.
Expand All @@ -793,7 +796,7 @@ protected function prepareMenuItemsForListMenu($specialValue)
$row['_MP_PARAM'] = $mount_info['MPvar'];
// Overlays should already have their full MPvars calculated
if ($mount_info['overlay']) {
$MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps((int)$mount_info['mount_pid']);
if ($MP) {
unset($row['_MP_PARAM']);
}
Expand Down

0 comments on commit d68a620

Please sign in to comment.