Skip to content

Commit 38c6e55

Browse files
committed
[BUGFIX] custom backend layout for v14
1 parent a50aaff commit 38c6e55

File tree

4 files changed

+119
-6
lines changed

4 files changed

+119
-6
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace B13\Container\Domain\Core;
6+
7+
/*
8+
* This file is part of TYPO3 CMS-based extension "container" by b13.
9+
*
10+
* It is free software; you can redistribute it and/or modify it under
11+
* the terms of the GNU General Public License, either version 2
12+
* of the License, or any later version.
13+
*/
14+
15+
use TYPO3\CMS\Core\Domain\RawRecord;
16+
use TYPO3\CMS\Core\Domain\Record;
17+
use TYPO3\CMS\Core\Domain\Record\ComputedProperties;
18+
use TYPO3\CMS\Core\Domain\Record\LanguageInfo;
19+
use TYPO3\CMS\Core\Domain\Record\SystemProperties;
20+
use TYPO3\CMS\Core\Domain\Record\VersionInfo;
21+
use TYPO3\CMS\Core\Domain\RecordInterface;
22+
23+
class RecordWithRenderedGrid implements RecordInterface
24+
{
25+
public function __construct(
26+
protected readonly Record $coreRecord,
27+
protected readonly ?string $renderedGrid
28+
) {
29+
}
30+
31+
public function getUid(): int
32+
{
33+
return $this->coreRecord->getRawRecord()->getUid();
34+
}
35+
36+
public function getPid(): int
37+
{
38+
return $this->coreRecord->getRawRecord()->getPid();
39+
}
40+
41+
public function getFullType(): string
42+
{
43+
return $this->coreRecord->getRawRecord()->getFullType();
44+
}
45+
46+
public function getRecordType(): ?string
47+
{
48+
return $this->coreRecord->getRawRecord()->getRecordType();
49+
}
50+
51+
public function getMainType(): string
52+
{
53+
return $this->coreRecord->getRawRecord()->getMainType();
54+
}
55+
56+
public function toArray(bool $includeSystemProperties = false): array
57+
{
58+
$properties = $this->coreRecord->toArray();
59+
$properties['tx_container_grid'] = $this->renderedGrid;
60+
return $properties;
61+
}
62+
63+
public function has(string $id): bool
64+
{
65+
if ($id === 'tx_container_grid') {
66+
return true;
67+
}
68+
return $this->coreRecord->has($id);
69+
}
70+
71+
public function get(string $id): mixed
72+
{
73+
if ($id === 'tx_container_grid') {
74+
return $this->renderedGrid;
75+
}
76+
return $this->coreRecord->get($id);
77+
}
78+
79+
public function getVersionInfo(): ?VersionInfo
80+
{
81+
return $this->coreRecord->getVersionInfo();
82+
}
83+
84+
public function getLanguageInfo(): ?LanguageInfo
85+
{
86+
return $this->coreRecord->getLanguageInfo();
87+
}
88+
89+
public function getLanguageId(): ?int
90+
{
91+
return $this->coreRecord->getLanguageId();
92+
}
93+
94+
public function getSystemProperties(): ?SystemProperties
95+
{
96+
return $this->coreRecord->getSystemProperties();
97+
}
98+
99+
public function getComputedProperties(): ComputedProperties
100+
{
101+
return $this->coreRecord->getComputedProperties();
102+
}
103+
104+
public function getRawRecord(): RawRecord
105+
{
106+
return $this->coreRecord->getRawRecord();
107+
}
108+
109+
public function getOverlaidUid(): int
110+
{
111+
return $this->coreRecord->getOverlaidUid();
112+
}
113+
}

Classes/Listener/PageContentPreviewRendering.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
*/
1414

1515
use B13\Container\Backend\Preview\GridRenderer;
16+
use B13\Container\Domain\Core\RecordWithRenderedGrid;
1617
use B13\Container\Tca\Registry;
1718
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent;
19+
use TYPO3\CMS\Core\Domain\Record;
1820
use TYPO3\CMS\Core\Information\Typo3Version;
1921
use TYPO3\CMS\Core\Utility\GeneralUtility;
2022

@@ -45,9 +47,10 @@ public function __invoke(PageContentPreviewRenderingEvent $event): void
4547
if (!$this->tcaRegistry->isContainerElement($recordType)) {
4648
return;
4749
}
48-
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 13) {
50+
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 13 && $record instanceof Record) {
4951
$previewContent = $this->gridRenderer->renderGrid($record->toArray(), $event->getPageLayoutContext());
50-
$event->setPreviewContent($previewContent);
52+
$recordWithRenderedGrid = new RecordWithRenderedGrid($record, $previewContent);
53+
$event->setRecord($recordWithRenderedGrid);
5154
} else {
5255
$record['tx_container_grid'] = $this->gridRenderer->renderGrid($record, $event->getPageLayoutContext());
5356
$event->setRecord($record);

Tests/Acceptance/Backend/LayoutCest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,6 @@ public function canSeeCustomBackendTemplate(BackendTester $I, PageTree $pageTree
482482
}
483483
$I->wait(0.2);
484484
$I->switchToContentFrame();
485-
if ($I->getTypo3MajorVersion() > 13) {
486-
$scenario->skip('need more work, PageContentPreviewRendering');
487-
}
488485
$I->waitForElement('#tx-container-example-custom-backend-template');
489486
$I->see('custom backend template');
490487
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030
},
3131
"require-dev": {
32-
"b13/container-example": "dev-master",
32+
"b13/container-example": "dev-task/v14-backend-template",
3333
"typo3/cms-install": "^11.5 || ^12.4 || ^13.4 || ^14.0",
3434
"typo3/cms-fluid-styled-content": "^11.5 || ^12.4 || ^13.4 || ^14.0",
3535
"typo3/cms-info": "^11.5 || ^12.4 || ^13.4 || ^14.0",

0 commit comments

Comments
 (0)