From 1af82869d2f15916fc43c18861d0e1d0186f3212 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 30 Oct 2025 18:49:25 +0100 Subject: [PATCH] [TASK] PageContentPreviewRenderingEvent changed in v14 property record changed from array to RecordInterface s. https://review.typo3.org/c/Packages/TYPO3.CMS/+/88519 --- Build/phpstan-baseline-11-7.4.neon | 15 +++++++++++++- Build/phpstan-baseline-11.neon | 15 +++++++++++++- Build/phpstan-baseline-12.neon | 20 ++++++++++++++++++- Build/phpstan-baseline-13.neon | 11 +++++++++- Build/phpstan-baseline-14.neon | 11 +++++++++- .../Backend/Grid/ContainerGridColumnItem.php | 7 +++++++ .../Listener/PageContentPreviewRendering.php | 19 +++++++++++++++--- 7 files changed, 90 insertions(+), 8 deletions(-) diff --git a/Build/phpstan-baseline-11-7.4.neon b/Build/phpstan-baseline-11-7.4.neon index 2c75833f..68e3a5a3 100644 --- a/Build/phpstan-baseline-11-7.4.neon +++ b/Build/phpstan-baseline-11-7.4.neon @@ -58,4 +58,17 @@ parameters: - message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Versioning\\\\VersionState\\:\\:tryFrom\\(\\)\\.$#" count: 2 - path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php \ No newline at end of file + path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php + - + message: "#^Cannot call method getRecordType\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + + - + message: "#^Cannot call method toArray\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + - + message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordFactory not found\\.$#" + count: 1 + path: ../Classes/Backend/Grid/ContainerGridColumnItem.php \ No newline at end of file diff --git a/Build/phpstan-baseline-11.neon b/Build/phpstan-baseline-11.neon index caee8086..2cf5ca0c 100644 --- a/Build/phpstan-baseline-11.neon +++ b/Build/phpstan-baseline-11.neon @@ -68,4 +68,17 @@ parameters: - message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Versioning\\\\VersionState\\:\\:tryFrom\\(\\)\\.$#" count: 2 - path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php \ No newline at end of file + path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php + - + message: "#^Cannot call method getRecordType\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + + - + message: "#^Cannot call method toArray\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + - + message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordFactory not found\\.$#" + count: 1 + path: ../Classes/Backend/Grid/ContainerGridColumnItem.php \ No newline at end of file diff --git a/Build/phpstan-baseline-12.neon b/Build/phpstan-baseline-12.neon index 578bec6b..e33674db 100644 --- a/Build/phpstan-baseline-12.neon +++ b/Build/phpstan-baseline-12.neon @@ -63,4 +63,22 @@ parameters: - message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Versioning\\\\VersionState\\:\\:tryFrom\\(\\)\\.$#" count: 2 - path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php \ No newline at end of file + path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php + - + message: "#^Cannot call method getRecordType\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + + - + message: "#^Cannot call method toArray\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + - + message: "#^Call to method createFromDatabaseRow\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordFactory\\.$#" + count: 1 + path: ../Classes/Backend/Grid/ContainerGridColumnItem.php + + - + message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordFactory not found\\.$#" + count: 1 + path: ../Classes/Backend/Grid/ContainerGridColumnItem.php \ No newline at end of file diff --git a/Build/phpstan-baseline-13.neon b/Build/phpstan-baseline-13.neon index 4ecc369d..c4790e6e 100644 --- a/Build/phpstan-baseline-13.neon +++ b/Build/phpstan-baseline-13.neon @@ -39,4 +39,13 @@ parameters: - message: "#^Class TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutContext constructor invoked with 2 parameters, 5 required\\.$#" count: 1 - path: ../Tests/Functional/Integrity/IntegrityTest.php \ No newline at end of file + path: ../Tests/Functional/Integrity/IntegrityTest.php + - + message: "#^Cannot call method getRecordType\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + + - + message: "#^Cannot call method toArray\\(\\) on array\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php diff --git a/Build/phpstan-baseline-14.neon b/Build/phpstan-baseline-14.neon index b29852fe..755c9660 100644 --- a/Build/phpstan-baseline-14.neon +++ b/Build/phpstan-baseline-14.neon @@ -78,4 +78,13 @@ parameters: - message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Versioning\\\\VersionState\\:\\:cast\\(\\)\\.$#" count: 2 - path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php \ No newline at end of file + path: ../Classes/Domain/Factory/PageView/Backend/ContentStorage.php + - + message: "#^Parameter \\#1 \\$record of method B13\\\\Container\\\\Backend\\\\Preview\\\\GridRenderer\\:\\:renderGrid\\(\\) expects array, TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordInterface given\\.$#" + count: 1 + path: ../Classes/Backend/Preview/ContainerPreviewRenderer.php + + - + message: "#^Parameter \\#1 \\$record of method B13\\\\Container\\\\Backend\\\\Preview\\\\GridRenderer\\:\\:renderGrid\\(\\) expects array, TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordInterface given\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php \ No newline at end of file diff --git a/Classes/Backend/Grid/ContainerGridColumnItem.php b/Classes/Backend/Grid/ContainerGridColumnItem.php index 17c034fa..7bde3e6c 100644 --- a/Classes/Backend/Grid/ContainerGridColumnItem.php +++ b/Classes/Backend/Grid/ContainerGridColumnItem.php @@ -15,6 +15,9 @@ use B13\Container\Domain\Model\Container; use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem; use TYPO3\CMS\Backend\View\PageLayoutContext; +use TYPO3\CMS\Core\Domain\RecordFactory; +use TYPO3\CMS\Core\Information\Typo3Version; +use TYPO3\CMS\Core\Utility\GeneralUtility; class ContainerGridColumnItem extends GridColumnItem { @@ -23,6 +26,10 @@ class ContainerGridColumnItem extends GridColumnItem public function __construct(PageLayoutContext $context, ContainerGridColumn $column, array $record, Container $container, ?string $newContentUrl) { + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 13) { + $recordFactory = GeneralUtility::makeInstance(RecordFactory::class); + $record = $recordFactory->createFromDatabaseRow('tt_content', $record); + } parent::__construct($context, $column, $record); $this->container = $container; $this->newContentUrl = $newContentUrl; diff --git a/Classes/Listener/PageContentPreviewRendering.php b/Classes/Listener/PageContentPreviewRendering.php index b6cf70db..776631de 100644 --- a/Classes/Listener/PageContentPreviewRendering.php +++ b/Classes/Listener/PageContentPreviewRendering.php @@ -15,6 +15,8 @@ use B13\Container\Backend\Preview\GridRenderer; use B13\Container\Tca\Registry; use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent; +use TYPO3\CMS\Core\Information\Typo3Version; +use TYPO3\CMS\Core\Utility\GeneralUtility; class PageContentPreviewRendering { @@ -34,10 +36,21 @@ public function __invoke(PageContentPreviewRenderingEvent $event): void } $record = $event->getRecord(); - if (!$this->tcaRegistry->isContainerElement((string)$record['CType'])) { + + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 13) { + $recordType = $record->getRecordType(); + } else { + $recordType = $record['CType']; + } + if (!$this->tcaRegistry->isContainerElement($recordType)) { return; } - $record['tx_container_grid'] = $this->gridRenderer->renderGrid($record, $event->getPageLayoutContext()); - $event->setRecord($record); + if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 13) { + $previewContent = $this->gridRenderer->renderGrid($record->toArray(), $event->getPageLayoutContext()); + $event->setPreviewContent($previewContent); + } else { + $record['tx_container_grid'] = $this->gridRenderer->renderGrid($record, $event->getPageLayoutContext()); + $event->setRecord($record); + } } }