Skip to content

Commit 8e45e40

Browse files
committed
[TASK] prepare v2
1 parent e42d6b1 commit 8e45e40

File tree

11 files changed

+50
-61
lines changed

11 files changed

+50
-61
lines changed

Classes/DataProcessing/ListItemsDataProcessor.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@
1313
*/
1414

1515
use B13\Listelements\Service\ListService;
16+
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
1617
use TYPO3\CMS\Core\Utility\GeneralUtility;
1718
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
1819
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
1920
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
2021

22+
#[Autoconfigure(public: true)]
2123
class ListItemsDataProcessor implements DataProcessorInterface
2224
{
23-
protected ListService $listService;
24-
protected ContentDataProcessor $contentDataProcessor;
25-
26-
public function __construct(ListService $listService, ContentDataProcessor $contentDataProcessor)
25+
public function __construct(protected ListService $listService, protected ContentDataProcessor $contentDataProcessor)
2726
{
28-
$this->listService = $listService;
29-
$this->contentDataProcessor = $contentDataProcessor;
3027
}
3128

3229
public function process(

Classes/Listener/PageContentPreviewRendering.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414

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

20+
#[AsEventListener(identifier: 'b13-listelements-page-content-preview-rendering')]
1921
class PageContentPreviewRendering
2022
{
21-
protected ListService $listService;
22-
23-
public function __construct(ListService $listService)
23+
public function __construct(protected ListService $listService)
2424
{
25-
$this->listService = $listService;
2625
}
2726

2827
public function __invoke(PageContentPreviewRenderingEvent $event): void

Classes/Service/ListService.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
2020
use TYPO3\CMS\Core\Information\Typo3Version;
2121
use TYPO3\CMS\Core\Resource\FileRepository;
22-
use TYPO3\CMS\Core\SingletonInterface;
2322
use TYPO3\CMS\Core\Utility\GeneralUtility;
2423
use TYPO3\CMS\Core\Versioning\VersionState;
2524

26-
class ListService implements SingletonInterface
25+
class ListService
2726
{
2827
private const TABLE = 'tx_listelements_item';
2928

@@ -79,9 +78,6 @@ public function resolveListitems(array $row, string $field = 'tx_listelements_li
7978

8079
protected function isDeletePlaceHolder(array $item): bool
8180
{
82-
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
83-
return VersionState::cast($item['t3ver_state'] ?? 0)->equals(VersionState::DELETE_PLACEHOLDER);
84-
}
8581
return VersionState::tryFrom($item['t3ver_state'] ?? 0) === VersionState::DELETE_PLACEHOLDER;
8682
}
8783

Configuration/Services.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,3 @@ services:
66

77
B13\Listelements\:
88
resource: '../Classes/*'
9-
10-
B13\Listelements\Hooks\DrawItem:
11-
public: true
12-
B13\Listelements\DataProcessing\ListItemsDataProcessor:
13-
public: true
14-
B13\Listelements\Listener\PageContentPreviewRendering:
15-
tags:
16-
- name: event.listener
17-
event: TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent
18-
identifier: 'b13-listelements-page-content-preview-rendering'

Configuration/Sets/listelements/setup.typoscript

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ lib.contentElement {
2222
}
2323
}
2424
}
25+
26+
# not required if you use record-transformation dataProcessing, s. README.md

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,33 @@ content element's Fluid template, like this:
2222
</f:for>
2323
```
2424

25+
### alternative: record-transformation dataProcessing
26+
27+
if you use record-transformation dataProcessing for your content-elements the EXT:listelements Site-Set (the TypoScript) is not required
28+
you can do
29+
30+
tt_content.<my-ce>.dataProcessing.10 = record-transformation
31+
32+
then you have adapt your templates, e.g.
33+
34+
```
35+
<f:for each="{record.tx_listelements_list}" as="item">
36+
...
37+
</f:for>
38+
```
39+
40+
and also the items self, e.g.
41+
42+
{item.header}
43+
{item.images}
44+
45+
instead of
46+
47+
{item.data.header}
48+
{item.listimages}
49+
50+
s. https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/DataProcessing/RecordTransformationProcessor.html
51+
2552
## Backend PageLayoutView preview
2653

2754
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

Tests/Functional/Fixture/Extensions/listelements-example/Configuration/TCA/Overrides/pages.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
'showSynchronizationLink' => false,
1717
'showAllLocalizationLink' => true,
1818
'showPossibleLocalizationRecords' => true,
19-
'showRemovedLocalizationRecords' => true,
2019
'expandSingle' => true,
2120
'newRecordLinkAddTitle' => false,
2221
'newRecordLinkTitle' => 'LLL:EXT:listelements/Resources/Private/Language/locallang_db.xlf:tt_content.list.newRecordLinkAddTitle',

Tests/Functional/Fixture/Extensions/listelements-example/Configuration/TypoScript/setup.typoscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
@import 'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript'
3-
@import 'EXT:listelements/Configuration/TypoScript/setup.typoscript'
3+
@import 'EXT:listelements/Configuration/Sets/listelements/setup.typoscript'
44

55
tt_content.header {
66
templateName = Header

Tests/Functional/Frontend/FrontendTest.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* of the License, or any later version.
1313
*/
1414

15+
use PHPUnit\Framework\Attributes\Test;
1516
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
1617
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
1718
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
@@ -38,9 +39,7 @@ class FrontendTest extends FunctionalTestCase
3839
'listelements_example',
3940
];
4041

41-
/**
42-
* @test
43-
*/
42+
#[Test]
4443
public function itemIsRendered(): void
4544
{
4645
$this->importCSVDataSet(__DIR__ . '/../Fixture/single_element.csv');
@@ -57,9 +56,7 @@ public function itemIsRendered(): void
5756
self::assertStringContainsString('listitem-header', $body);
5857
}
5958

60-
/**
61-
* @test
62-
*/
59+
#[Test]
6360
public function workspaceItemIsRenderedInWorkspace(): void
6461
{
6562
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');
@@ -81,9 +78,7 @@ public function workspaceItemIsRenderedInWorkspace(): void
8178
self::assertStringNotContainsString('listitem-header', $body);
8279
}
8380

84-
/**
85-
* @test
86-
*/
81+
#[Test]
8782
public function worspaceItemIsNotRenderedInNonWorkspace(): void
8883
{
8984
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');
@@ -104,9 +99,7 @@ public function worspaceItemIsNotRenderedInNonWorkspace(): void
10499
self::assertStringContainsString('listitem-header', $body);
105100
}
106101

107-
/**
108-
* @test
109-
*/
102+
#[Test]
110103
public function workspaceItemsIsRenderedInCorrectOrderInWorkspace(): void
111104
{
112105
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');
@@ -127,9 +120,7 @@ public function workspaceItemsIsRenderedInCorrectOrderInWorkspace(): void
127120
self::assertStringContainsString('first item header-listelement-ws', $body);
128121
}
129122

130-
/**
131-
* @test
132-
*/
123+
#[Test]
133124
public function deletedworkspaceItemIsNotRenderedInWorkspace(): void
134125
{
135126
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');
@@ -150,9 +141,7 @@ public function deletedworkspaceItemIsNotRenderedInWorkspace(): void
150141
self::assertStringNotContainsString('listitem-header', $body);
151142
}
152143

153-
/**
154-
* @test
155-
*/
144+
#[Test]
156145
public function pageItemIsRendered(): void
157146
{
158147
$this->importCSVDataSet(__DIR__ . '/../Fixture/page.csv');

Tests/Functional/Service/ListServiceTest.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
use B13\Listelements\Service\ListService;
16+
use PHPUnit\Framework\Attributes\Test;
1617
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
1718
use TYPO3\CMS\Core\Context\Context;
1819
use TYPO3\CMS\Core\Context\WorkspaceAspect;
@@ -37,9 +38,7 @@ class ListServiceTest extends FunctionalTestCase
3738
'listelements',
3839
];
3940

40-
/**
41-
* @test
42-
*/
41+
#[Test]
4342
public function itemIsFound(): void
4443
{
4544
$this->importCSVDataSet(__DIR__ . '/../Fixture/single_element.csv');
@@ -51,9 +50,7 @@ public function itemIsFound(): void
5150
self::assertSame('listitem-header', $row['listitems'][0]['header']);
5251
}
5352

54-
/**
55-
* @test
56-
*/
53+
#[Test]
5754
public function workspaceItemIsFoundInWorkspace(): void
5855
{
5956
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');
@@ -67,9 +64,7 @@ public function workspaceItemIsFoundInWorkspace(): void
6764
self::assertSame('header-listelement-ws', $row['listitems'][0]['header']);
6865
}
6966

70-
/**
71-
* @test
72-
*/
67+
#[Test]
7368
public function liveItemIsFoundInNonWorkspace(): void
7469
{
7570
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');
@@ -82,9 +77,7 @@ public function liveItemIsFoundInNonWorkspace(): void
8277
self::assertSame('listitem-header', $row['listitems'][0]['header']);
8378
}
8479

85-
/**
86-
* @test
87-
*/
80+
#[Test]
8881
public function deletedWorkspaceItemsAreNotListedInWorkspace(): void
8982
{
9083
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');
@@ -96,9 +89,7 @@ public function deletedWorkspaceItemsAreNotListedInWorkspace(): void
9689
self::assertSame(0, count($row['listitems']));
9790
}
9891

99-
/**
100-
* @test
101-
*/
92+
#[Test]
10293
public function workspaceItemsHasCorrectOrderInWorkspace(): void
10394
{
10495
$this->importCSVDataSet(__DIR__ . '/../Fixture/workspace.csv');

0 commit comments

Comments
 (0)