diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2f9d0c..e988ec9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - TYPO3: [ '11' , '12', '13', '14' ] + TYPO3: [ '12', '13', '14' ] steps: - name: Checkout @@ -39,27 +39,20 @@ jobs: - name: Install composer dependencies TYPO3 13 if: matrix.TYPO3 == '13' run: | - composer install --no-progress --no-interaction + composer require typo3/cms-core:^13.4 --no-progress --no-interaction --dev -W - name: Install composer dependencies TYPO3 12 if: matrix.TYPO3 == '12' run: | composer require typo3/cms-core:^12.4 --no-progress --no-interaction --dev -W - - name: Install composer dependencies TYPO3 11 - if: matrix.TYPO3 == '11' - run: | - composer require typo3/cms-core:^11.5 --no-progress --no-interaction --dev -W - - name: Phpstan 14 - if: matrix.TYPO3 == '14' - run: .Build/bin/phpstan analyze -c Build/phpstan.neon - name: Phpstan 13 if: matrix.TYPO3 == '13' + run: .Build/bin/phpstan analyze -c Build/phpstan13.neon + - name: Phpstan 14 + if: matrix.TYPO3 == '14' run: .Build/bin/phpstan analyze -c Build/phpstan.neon - name: Phpstan 12 if: matrix.TYPO3 == '12' run: .Build/bin/phpstan analyze -c Build/phpstan12.neon - - name: Phpstan 11 - if: matrix.TYPO3 == '11' - run: .Build/bin/phpstan analyze -c Build/phpstan11.neon - name: Phpcsfix run: .Build/bin/php-cs-fixer fix --config=Build/php-cs-fixer.php --dry-run --stop-on-violation --using-cache=no - name: Functional Tests diff --git a/Build/phpstan-baseline.neon b/Build/phpstan-baseline.neon new file mode 100644 index 0000000..1de27c9 --- /dev/null +++ b/Build/phpstan-baseline.neon @@ -0,0 +1,21 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$record of method TYPO3\\\\CMS\\\\Backend\\\\View\\\\Event\\\\PageContentPreviewRenderingEvent\\:\\:setRecord\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordInterface, array given\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + + - + message: "#^Parameter \\#1 \\$row of method B13\\\\Listelements\\\\Service\\\\ListService\\:\\:resolveListitems\\(\\) expects array, TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordInterface given\\.$#" + count: 1 + path: ../Classes/Listener/PageContentPreviewRendering.php + + - + message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:enableFields\\(\\)\\.$#" + count: 1 + path: ../Classes/Service/ListService.php + + - + message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Versioning\\\\VersionState\\:\\:cast\\(\\)\\.$#" + count: 1 + path: ../Classes/Service/ListService.php diff --git a/Build/phpstan.neon b/Build/phpstan.neon index 113759d..1d50b1c 100644 --- a/Build/phpstan.neon +++ b/Build/phpstan.neon @@ -1,5 +1,5 @@ includes: - - ../.Build/vendor/saschaegerer/phpstan-typo3/extension.neon + - phpstan-baseline.neon parameters: level: 5 paths: diff --git a/Build/phpstan11.neon b/Build/phpstan11.neon index 6bf52c2..b01e92c 100644 --- a/Build/phpstan11.neon +++ b/Build/phpstan11.neon @@ -1,5 +1,3 @@ -includes: - - ../.Build/vendor/saschaegerer/phpstan-typo3/extension.neon parameters: level: 5 paths: diff --git a/Build/phpstan12.neon b/Build/phpstan12.neon index 9857690..cba818e 100644 --- a/Build/phpstan12.neon +++ b/Build/phpstan12.neon @@ -1,5 +1,3 @@ -includes: - - ../.Build/vendor/saschaegerer/phpstan-typo3/extension.neon parameters: level: 5 paths: diff --git a/Build/phpstan13.neon b/Build/phpstan13.neon new file mode 100644 index 0000000..1804dd4 --- /dev/null +++ b/Build/phpstan13.neon @@ -0,0 +1,6 @@ +parameters: + level: 5 + paths: + - %currentWorkingDirectory%/Classes + excludePaths: + - %currentWorkingDirectory%/Classes/Hooks/DrawItem.php \ No newline at end of file diff --git a/Classes/Listener/PageContentPreviewRendering.php b/Classes/Listener/PageContentPreviewRendering.php index 033c9c7..f36cc66 100644 --- a/Classes/Listener/PageContentPreviewRendering.php +++ b/Classes/Listener/PageContentPreviewRendering.php @@ -14,6 +14,7 @@ use B13\Listelements\Service\ListService; use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent; +use TYPO3\CMS\Core\Information\Typo3Version; class PageContentPreviewRendering { @@ -26,6 +27,9 @@ public function __construct(ListService $listService) public function __invoke(PageContentPreviewRenderingEvent $event): void { + if ((new Typo3Version())->getMajorVersion() > 13) { + return; + } $record = $event->getRecord(); if ($record['tx_listelements_list'] ?? false) { $record = $this->listService->resolveListitems($record); diff --git a/Classes/Service/ListService.php b/Classes/Service/ListService.php index 19cd016..cfe0db7 100644 --- a/Classes/Service/ListService.php +++ b/Classes/Service/ListService.php @@ -36,6 +36,7 @@ class ListService implements SingletonInterface */ public function resolveListitems(array $row, string $field = 'tx_listelements_list', string $table = 'tt_content', string $filereferences = 'assets,images'): array { + // used for BE in TYPO3 < 14 $returnAs = 'listitems_' . $field; if ($returnAs === 'listitems_tx_listelements_list') { $returnAs = 'listitems'; @@ -96,11 +97,12 @@ public function resolveItemsForFrontend(int $uid, string $table = 'tt_content', $constraints = $pageRepository->getDefaultConstraints(self::TABLE); if ($constraints === []) { $additionalWhere = ''; + } else { + $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) + ->getQueryBuilderForTable($table) + ->expr(); + $additionalWhere = ' AND ' . $expressionBuilder->and(...$constraints); } - $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) - ->getQueryBuilderForTable($table) - ->expr(); - $additionalWhere = ' AND ' . $expressionBuilder->and(...$constraints); } $relationHandler->additionalWhere[self::TABLE] = $additionalWhere; $relationHandler->start( diff --git a/README.md b/README.md index 23ddf69..c1c02a1 100644 --- a/README.md +++ b/README.md @@ -24,48 +24,49 @@ content element's Fluid template, like this: ## Backend PageLayoutView preview -This extension adds a Hook and a Service class to allow customized display using Fluid templates for the backend Page -Layout View. Use this to add customized preview data if you add additional assets/image fields to be resolved for -backend preview: +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 +Layout View. -`EXT:site_extension/Classes/Hooks/DrawItem.php`: +For TYPO3 Version > 12 the Listener is not required anymore, because TYPO3 use the Record Api to resolve relations automatically. +For TYPO3 Version > 13 the Listener is not used anymore (because the Event changed) + +s. https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/14.0/Breaking-92434-UseRecordAPIInPageModulePreviewRendering.html + +Migrate or BE-Templates + +old: + +```html + ``` - + +
  • + {item.header} + + + + + +
  • +
    + ``` ## Important info on configuration diff --git a/composer.json b/composer.json index a30926e..bd144b4 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,12 @@ "minimum-stability": "dev", "prefer-stable": true, "require-dev": { - "typo3/testing-framework": "^7.0 || ^8.0", + "typo3/testing-framework": "^7.0 || ^8.0 || ^9.1", "typo3/cms-frontend": "^11.5 || ^12.4 || ^13.1 || ^14.0", "typo3/cms-workspaces": "^11.5 || ^12.4 || ^13.1 || ^14.0", - "saschaegerer/phpstan-typo3": "^1.8", + "phpstan/phpstan": "^1.10", "typo3/coding-standards": "^0.5.5", + "phpunit/phpunit": "9.6 || ^10.5 || ^11.3", "b13/listelements-example": "*" }, "autoload-dev": {