[TASK] Insert hook for simulatestatic
authorMarkus Klein <klein.t3@mfc-linz.at>
Fri, 21 Sep 2012 11:26:16 +0000 (13:26 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 22 Sep 2012 22:36:07 +0000 (00:36 +0200)
Resolves: #36025
Releases: 6.0
Change-Id: I5d88626a6062ccdc69eb389664ced529a72d2f7b
Reviewed-on: http://review.typo3.org/10452
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php

index 79ce64d..31b8fbf 100644 (file)
@@ -1291,6 +1291,28 @@ class TypoScriptFrontendController {
                // Still used in the old wapversion.lib files.
                $this->idParts = explode(',', $this->id);
                $this->id = $this->idParts[0];
+
+                       // Hook for further id manipulation
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'])) {
+                       $_params = array('id' => $this->id);
+                       $newId = FALSE;
+                       foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'] as $_funcRef) {
+                               $deprecationMessage = 'Hook $TYPO3_CONF_VARS[SC_OPTIONS][tslib/class.tslib_fe.php][modifyPageId] is ' .
+                                       'deprecated since 6.0 and will be removed two versions later';
+                               if (!is_object($_funcRef) || !is_a($_funcRef, 'Closure')) {
+                                       $deprecationMessage .= '- used by ' . $_funcRef;
+                               }
+                               \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog($deprecationMessage);
+                               $newIdFromFunc = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this);
+                               if ($newIdFromFunc !== FALSE) {
+                                       $newId = $newIdFromFunc;
+                               }
+                       }
+                       if ($newId !== FALSE) {
+                               $this->id = $newId;
+                       }
+               }
+
                // If $this->id is a string, it's an alias
                $this->checkAndSetAlias();
                // The id and type is set to the integer-value - just to be sure...
index 001f499..3f0d984 100644 (file)
@@ -154,6 +154,40 @@ class TypoScriptFrontendControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
                $this->assertEquals($clearText, $this->fixture->_callRef('roundTripCryptString', $refValue));
        }
 
+       /**
+        * @test
+        */
+       public function isModifyPageIdTestCalled() {
+               $GLOBALS['TT'] = $this->getMock('TYPO3\\CMS\Core\\TimeTracker\\TimeTracker');
+               $this->fixture = $this->getMock(
+                       '\\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
+                       array(
+                               'initUserGroups',
+                               'setSysPageWhereClause',
+                               'checkAndSetAlias',
+                               'findDomainRecord',
+                               'getPageAndRootlineWithDomain'
+                       ),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $pageRepository = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
+               \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository', $pageRepository);
+
+               $initialId = rand(1, 500);
+               $expectedId = $initialId + 42;
+               $this->fixture->id = $initialId;
+
+               $this->fixture->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'][] = function($params, $frontendController) {
+                       return $params['id'] + 42;
+               };
+
+               $this->fixture->fetch_the_id();
+               $this->assertSame($expectedId, $this->fixture->id);
+       }
+
 }
 
-?>
\ No newline at end of file
+?>