Skip to content

Commit e5b1a93

Browse files
committed
[TASK] TYPO3 v14 Support
* do not use PageContentPreviewRendering for resolving listitems * cleanup github ci * rm v11 from ci
1 parent 6ef309d commit e5b1a93

File tree

10 files changed

+85
-62
lines changed

10 files changed

+85
-62
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
TYPO3: [ '11' , '12', '13', '14' ]
11+
TYPO3: [ '12', '13', '14' ]
1212

1313
steps:
1414
- name: Checkout
@@ -39,27 +39,20 @@ jobs:
3939
- name: Install composer dependencies TYPO3 13
4040
if: matrix.TYPO3 == '13'
4141
run: |
42-
composer install --no-progress --no-interaction
42+
composer require typo3/cms-core:^13.4 --no-progress --no-interaction --dev -W
4343
- name: Install composer dependencies TYPO3 12
4444
if: matrix.TYPO3 == '12'
4545
run: |
4646
composer require typo3/cms-core:^12.4 --no-progress --no-interaction --dev -W
47-
- name: Install composer dependencies TYPO3 11
48-
if: matrix.TYPO3 == '11'
49-
run: |
50-
composer require typo3/cms-core:^11.5 --no-progress --no-interaction --dev -W
51-
- name: Phpstan 14
52-
if: matrix.TYPO3 == '14'
53-
run: .Build/bin/phpstan analyze -c Build/phpstan.neon
5447
- name: Phpstan 13
5548
if: matrix.TYPO3 == '13'
49+
run: .Build/bin/phpstan analyze -c Build/phpstan13.neon
50+
- name: Phpstan 14
51+
if: matrix.TYPO3 == '14'
5652
run: .Build/bin/phpstan analyze -c Build/phpstan.neon
5753
- name: Phpstan 12
5854
if: matrix.TYPO3 == '12'
5955
run: .Build/bin/phpstan analyze -c Build/phpstan12.neon
60-
- name: Phpstan 11
61-
if: matrix.TYPO3 == '11'
62-
run: .Build/bin/phpstan analyze -c Build/phpstan11.neon
6356
- name: Phpcsfix
6457
run: .Build/bin/php-cs-fixer fix --config=Build/php-cs-fixer.php --dry-run --stop-on-violation --using-cache=no
6558
- name: Functional Tests

Build/phpstan-baseline.neon

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#1 \\$record of method TYPO3\\\\CMS\\\\Backend\\\\View\\\\Event\\\\PageContentPreviewRenderingEvent\\:\\:setRecord\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordInterface, array given\\.$#"
5+
count: 1
6+
path: ../Classes/Listener/PageContentPreviewRendering.php
7+
8+
-
9+
message: "#^Parameter \\#1 \\$row of method B13\\\\Listelements\\\\Service\\\\ListService\\:\\:resolveListitems\\(\\) expects array, TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordInterface given\\.$#"
10+
count: 1
11+
path: ../Classes/Listener/PageContentPreviewRendering.php
12+
13+
-
14+
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:enableFields\\(\\)\\.$#"
15+
count: 1
16+
path: ../Classes/Service/ListService.php
17+
18+
-
19+
message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Versioning\\\\VersionState\\:\\:cast\\(\\)\\.$#"
20+
count: 1
21+
path: ../Classes/Service/ListService.php

Build/phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- ../.Build/vendor/saschaegerer/phpstan-typo3/extension.neon
2+
- phpstan-baseline.neon
33
parameters:
44
level: 5
55
paths:

Build/phpstan11.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
includes:
2-
- ../.Build/vendor/saschaegerer/phpstan-typo3/extension.neon
31
parameters:
42
level: 5
53
paths:

Build/phpstan12.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
includes:
2-
- ../.Build/vendor/saschaegerer/phpstan-typo3/extension.neon
31
parameters:
42
level: 5
53
paths:

Build/phpstan13.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 5
3+
paths:
4+
- %currentWorkingDirectory%/Classes
5+
excludePaths:
6+
- %currentWorkingDirectory%/Classes/Hooks/DrawItem.php

Classes/Listener/PageContentPreviewRendering.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use B13\Listelements\Service\ListService;
1616
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent;
17+
use TYPO3\CMS\Core\Information\Typo3Version;
1718

1819
class PageContentPreviewRendering
1920
{
@@ -26,6 +27,9 @@ public function __construct(ListService $listService)
2627

2728
public function __invoke(PageContentPreviewRenderingEvent $event): void
2829
{
30+
if ((new Typo3Version())->getMajorVersion() > 13) {
31+
return;
32+
}
2933
$record = $event->getRecord();
3034
if ($record['tx_listelements_list'] ?? false) {
3135
$record = $this->listService->resolveListitems($record);

Classes/Service/ListService.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ListService implements SingletonInterface
3636
*/
3737
public function resolveListitems(array $row, string $field = 'tx_listelements_list', string $table = 'tt_content', string $filereferences = 'assets,images'): array
3838
{
39+
// used for BE in TYPO3 < 14
3940
$returnAs = 'listitems_' . $field;
4041
if ($returnAs === 'listitems_tx_listelements_list') {
4142
$returnAs = 'listitems';
@@ -96,11 +97,12 @@ public function resolveItemsForFrontend(int $uid, string $table = 'tt_content',
9697
$constraints = $pageRepository->getDefaultConstraints(self::TABLE);
9798
if ($constraints === []) {
9899
$additionalWhere = '';
100+
} else {
101+
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
102+
->getQueryBuilderForTable($table)
103+
->expr();
104+
$additionalWhere = ' AND ' . $expressionBuilder->and(...$constraints);
99105
}
100-
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
101-
->getQueryBuilderForTable($table)
102-
->expr();
103-
$additionalWhere = ' AND ' . $expressionBuilder->and(...$constraints);
104106
}
105107
$relationHandler->additionalWhere[self::TABLE] = $additionalWhere;
106108
$relationHandler->start(

README.md

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,49 @@ content element's Fluid template, like this:
2424

2525
## Backend PageLayoutView preview
2626

27-
This extension adds a Hook and a Service class to allow customized display using Fluid templates for the backend Page
28-
Layout View. Use this to add customized preview data if you add additional assets/image fields to be resolved for
29-
backend preview:
27+
This extension adds a PageContentPreviewRendering Listener to resolve ListItems (and if needed further Relations to asses/images) to allow customized display using Fluid templates for the backend Page
28+
Layout View.
3029

31-
`EXT:site_extension/Classes/Hooks/DrawItem.php`:
30+
For TYPO3 Version > 12 the Listener is not required anymore, because TYPO3 use the Record Api to resolve relations automatically.
3231

32+
For TYPO3 Version > 13 the Listener is not used anymore (because the Event changed)
33+
34+
s. https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/14.0/Breaking-92434-UseRecordAPIInPageModulePreviewRendering.html
35+
36+
Migrate or BE-Templates
37+
38+
old:
39+
40+
```html
41+
<ul>
42+
<f:for each="{listitems}" as="item">
43+
<li>
44+
{item.header}
45+
<f:if condition="{item.processedImages}">
46+
<f:for each="{item.processedImages}" as="image">
47+
<f:image src="{image.uid}" treatIdAsReference="true"/>
48+
</f:for>
49+
</f:if>
50+
</li>
51+
</f:for>
52+
</ul>
3353
```
34-
<?php
35-
36-
namespace B13\SiteExtension\Hooks;
37-
38-
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
39-
use TYPO3\CMS\Backend\View\PageLayoutView;
40-
41-
/**
42-
* Class/Function to manipulate the rendering of item preview content
43-
*
44-
*/
45-
class DrawItem implements PageLayoutViewDrawItemHookInterface
46-
{
47-
48-
/**
49-
* @param PageLayoutView $parentObject : The parent object that triggered this hook
50-
* @param boolean $drawItem : A switch to tell the parent object, if the item still must be drawn
51-
* @param string $headerContent : The content of the item header
52-
* @param string $itemContent : The content of the item itself
53-
* @param array $row : The current data row for this item
54-
*
55-
* @return void
56-
*/
57-
public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
58-
{
59-
60-
// get all list items (database column 'test_list') including all assets
61-
if ($row['test_list']) {
62-
// array &$row, $field = '', $table = 'tt_content', $filereferences = 'assets, additional_assets'
63-
\B13\Listelements\Service\ListService::resolveListitems($row, 'test_list', 'tt_content');
64-
}
65-
66-
}
67-
68-
}
54+
55+
new:
56+
57+
```html
58+
<ul>
59+
<f:for each="{record.tx_listelements_list}" as="item">
60+
<li>
61+
{item.header}
62+
<f:if condition="{item.images}">
63+
<f:for each="{item.images}" as="image">
64+
<f:image src="{image.uid}" treatIdAsReference="true"/>
65+
</f:for>
66+
</f:if>
67+
</li>
68+
</f:for>
69+
</ul>
6970
```
7071

7172
## Important info on configuration

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"minimum-stability": "dev",
2222
"prefer-stable": true,
2323
"require-dev": {
24-
"typo3/testing-framework": "^7.0 || ^8.0",
24+
"typo3/testing-framework": "^7.0 || ^8.0 || ^9.1",
2525
"typo3/cms-frontend": "^11.5 || ^12.4 || ^13.1 || ^14.0",
2626
"typo3/cms-workspaces": "^11.5 || ^12.4 || ^13.1 || ^14.0",
27-
"saschaegerer/phpstan-typo3": "^1.8",
27+
"phpstan/phpstan": "^1.10",
2828
"typo3/coding-standards": "^0.5.5",
2929
"b13/listelements-example": "*"
3030
},

0 commit comments

Comments
 (0)