Skip to content

Commit fad77d3

Browse files
committed
[BUGFIX] Use rootline utility to retrieve rootline
Since the new API is available in TYPO3 9.5 and the old was removed in 10.4, we need to use the new API now.
1 parent b24369d commit fad77d3

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

Classes/Renderer/RecordRenderer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Helhum\TyposcriptRendering\Mvc\Request;
1717
use Helhum\TyposcriptRendering\Mvc\Response;
1818
use TYPO3\CMS\Core\Utility\GeneralUtility;
19+
use TYPO3\CMS\Core\Utility\RootlineUtility;
1920
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
2021

2122
/**
@@ -84,7 +85,7 @@ protected function resolveRenderingConfiguration(Request $request, RenderingCont
8485

8586
if ($table === 'pages') {
8687
// Allow rendering of a root page which has pid === 0 and would be denied otherwise
87-
$rootLine = $renderingContext->getFrontendController()->sys_page->getRootLine($id);
88+
$rootLine = GeneralUtility::makeInstance(RootlineUtility::class, $id)->get();
8889
// $rootLine[0] is the root page. Check if the page we're going to render is a root page.
8990
// We explicitly ignore the case where the to be rendered id is in another root line (multi domain setup)
9091
// as this would require an additional record lookup. The use case for this is very limited anyway

Tests/Unit/Renderer/RecordRendererTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Helhum\TyposcriptRendering\Renderer\RecordRenderer;
1818
use Helhum\TyposcriptRendering\Renderer\RenderingContext;
1919
use Nimut\TestingFramework\TestCase\UnitTestCase;
20+
use TYPO3\CMS\Core\Utility\GeneralUtility;
21+
use TYPO3\CMS\Core\Utility\RootlineUtility;
2022
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
2123

2224
/**
@@ -34,6 +36,11 @@ protected function setUp()
3436
$this->renderer = $this->getAccessibleMock('Helhum\\TyposcriptRendering\\Renderer\\RecordRenderer', ['dummy']);
3537
}
3638

39+
protected function tearDown()
40+
{
41+
GeneralUtility::purgeInstances();
42+
}
43+
3744
/**
3845
* @return array
3946
*/
@@ -102,20 +109,20 @@ public function configurationDataProvider()
102109
public function configurationIsGeneratedCorrectlyFromRequest(array $requestArguments, array $expectedConfiguration, $pageId = '42')
103110
{
104111
/** @var TypoScriptFrontendController|\PHPUnit_Framework_MockObject_MockObject $tsfeMock */
105-
$tsfeMock = $this->getMockBuilder('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController')
112+
$tsfeMock = $this->getMockBuilder(TypoScriptFrontendController::class)
106113
->disableOriginalConstructor()
107114
->getMock();
108-
$pageRepositoryMock = $this->getMockBuilder('TYPO3\\CMS\\Frontend\\Page\\PageRepository')->disableOriginalConstructor()->getMock();
109-
$pageRepositoryMock->expects($this->any())->method('getRootLine')->willReturn(
115+
$rootlineUtilityMock = $this->getMockBuilder(RootlineUtility::class)->disableOriginalConstructor()->getMock();
116+
$rootlineUtilityMock->expects($this->any())->method('get')->willReturn(
110117
[
111118
[
112119
'uid' => '1',
113120
'pid' => '0',
114121
],
115122
]
116123
);
124+
GeneralUtility::addInstance(RootlineUtility::class, $rootlineUtilityMock);
117125
$tsfeMock->id = $pageId;
118-
$tsfeMock->sys_page = $pageRepositoryMock;
119126
$contextFixture = new RenderingContext($tsfeMock);
120127
$requestFixture = new Request($requestArguments);
121128

0 commit comments

Comments
 (0)