diff --git a/Classes/Form/FormDataProvider/RichtextEncoreConfiguration.php b/Classes/Form/FormDataProvider/RichtextEncoreConfiguration.php index 188d2e8..119b837 100644 --- a/Classes/Form/FormDataProvider/RichtextEncoreConfiguration.php +++ b/Classes/Form/FormDataProvider/RichtextEncoreConfiguration.php @@ -15,24 +15,17 @@ use Ssch\Typo3Encore\Asset\EntrypointLookupCollectionInterface; use Ssch\Typo3Encore\Asset\EntrypointLookupInterface; use TYPO3\CMS\Backend\Form\FormDataProviderInterface; -use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; final class RichtextEncoreConfiguration implements FormDataProviderInterface { private EntrypointLookupCollectionInterface $entrypointLookupCollection; - private int $majorVersion = 12; - - public function __construct( - EntrypointLookupCollectionInterface $entrypointLookupCollection = null, - Typo3Version $typo3Version = null - ) { + public function __construct(EntrypointLookupCollectionInterface $entrypointLookupCollection = null) + { $this->entrypointLookupCollection = $entrypointLookupCollection ?? GeneralUtility::makeInstance( EntrypointLookupCollection::class ); - $typo3Version = $typo3Version ?? GeneralUtility::makeInstance(Typo3Version::class); - $this->majorVersion = $typo3Version->getMajorVersion(); } public function addData(array $result): array @@ -52,32 +45,26 @@ public function addData(array $result): array if (! isset($rteConfiguration['editor']['config']['contentsCss'])) { continue; } - $contentsCss = $rteConfiguration['editor']['config']['contentsCss']; - - if (is_array($contentsCss) && $this->majorVersion < 12) { - $updatedContentCss = []; - foreach ($contentsCss as $cssFile) { - $updatedContent = $this->getContentCss($cssFile); - $updatedContentCss[] = is_array($updatedContent) ? $updatedContent : [$updatedContent]; - } - $contentsCss = array_merge(...$updatedContentCss); - } elseif (is_string($contentsCss)) { - $contentsCss = $this->getContentCss($contentsCss); + $contentsCss = (array) $rteConfiguration['editor']['config']['contentsCss']; + + $updatedContentCss = []; + foreach ($contentsCss as $cssFile) { + $updatedContent = $this->getContentCss($cssFile); + $updatedContentCss[] = is_array($updatedContent) ? $updatedContent : [$updatedContent]; } + $contentsCss = array_merge(...$updatedContentCss); + $result['processedTca']['columns'][$fieldName]['config']['richtextConfiguration']['editor']['config']['contentsCss'] = $contentsCss; } return $result; } - /** - * @return array|string - */ - private function getContentCss(string $contentsCss) + private function getContentCss(string $contentsCss): array { if (! str_starts_with($contentsCss, 'typo3_encore:')) { // keep the css file as-is - return ($this->majorVersion < 12) ? [$contentsCss] : $contentsCss; + return [$contentsCss]; } // strip prefix @@ -96,10 +83,7 @@ private function getContentCss(string $contentsCss) // call reset() to allow multiple RTEs on the same page. // Otherwise only the first RTE will have the CSS. $entryPointLookup->reset(); - if ($this->majorVersion < 12) { - return $cssFiles; - } - // TYPO3 12 support only one css file. See https://forge.typo3.org/issues/99327 - return reset($cssFiles); + + return $cssFiles; } } diff --git a/composer.json b/composer.json index 1ae4583..5d74bea 100644 --- a/composer.json +++ b/composer.json @@ -20,17 +20,17 @@ "minimum-stability": "dev", "require": { "php": ">=7.4", - "typo3/cms-core": "^10.4.2 || ^11.5 || ^12", + "typo3/cms-core": "^10.4.2 || ^11.5 || ^12.4", "symfony/web-link": "^5.4 || ^6", "symfony/asset": "^5.0 || ^6", "ext-dom": "*", - "typo3/cms-tstemplate": "^10.4.2 || ^11.2 || ^12", + "typo3/cms-tstemplate": "^10.4.2 || ^11.5 || ^12.4", "webmozart/assert": "^1.10" }, "require-dev": { "phpstan/phpstan": "^1.0", "typo3/testing-framework": "^6.2 || dev-main", - "typo3/minimal": "^10.4 || ^11.5 || ^12.0", + "typo3/minimal": "^10.4 || ^11.5 || ^12.4", "php-parallel-lint/php-parallel-lint": "^1.3", "phpspec/prophecy-phpunit": "^2.0", "rector/rector": "^0.15.2", @@ -42,7 +42,7 @@ "saschaegerer/phpstan-typo3": "^1.8.0", "symplify/easy-coding-standard": "^11.0", "phpstan/phpstan-strict-rules": "^1.4.4", - "typo3/cms-rte-ckeditor": "^10.4 || ^11.5 || ^12.0" + "typo3/cms-rte-ckeditor": "^10.4 || ^11.5 || ^12.4" }, "replace": { "typo3-ter/typo3-encore": "self.version" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5435b79..20bb3f9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -16,44 +16,19 @@ parameters: path: Classes/Asset/TagRenderer.php - - message: "#^Strict comparison using \\!\\=\\= between '' and '1' will always evaluate to true\\.$#" - count: 1 - path: Classes/Middleware/AssetsMiddleware.php - - - - message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" - count: 1 - path: Classes/ViewHelpers/Stimulus/ActionViewHelper.php - - - - message: "#^Only booleans are allowed in \\|\\|, mixed given on the left side\\.$#" + message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#" count: 1 - path: Classes/ViewHelpers/Stimulus/ActionViewHelper.php + path: Classes/Form/FormDataProvider/RichtextEncoreConfiguration.php - - message: "#^Only booleans are allowed in \\|\\|, mixed given on the right side\\.$#" + message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" count: 1 - path: Classes/ViewHelpers/Stimulus/ActionViewHelper.php + path: Classes/Form/FormDataProvider/RichtextEncoreConfiguration.php - - message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" - count: 1 - path: Classes/ViewHelpers/Stimulus/ControllerViewHelper.php - - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 1 - path: Classes/ViewHelpers/Stimulus/ControllerViewHelper.php - - - - message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" - count: 1 - path: Classes/ViewHelpers/Stimulus/TargetViewHelper.php - - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + message: "#^Strict comparison using \\!\\=\\= between '' and '1' will always evaluate to true\\.$#" count: 1 - path: Classes/ViewHelpers/Stimulus/TargetViewHelper.php + path: Classes/Middleware/AssetsMiddleware.php - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"