diff --git a/config/v11/typo3-110.php b/config/v11/typo3-110.php index 0d6ddff33..192954292 100644 --- a/config/v11/typo3-110.php +++ b/config/v11/typo3-110.php @@ -6,6 +6,7 @@ use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; use Rector\Transform\ValueObject\StaticCallToFuncCall; +use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\TemplateToFluidTemplateTypoScriptRector; use Ssch\TYPO3Rector\Rector\v11\v0\DateTimeAspectInsteadOfGlobalsExecTimeRector; use Ssch\TYPO3Rector\Rector\v11\v0\ExtbaseControllerActionsMustReturnResponseInterfaceRector; use Ssch\TYPO3Rector\Rector\v11\v0\ForwardResponseInsteadOfForwardMethodRector; @@ -37,4 +38,5 @@ ), ]); $rectorConfig->rule(ReplaceInjectAnnotationWithMethodRector::class); + $rectorConfig->rule(TemplateToFluidTemplateTypoScriptRector::class); }; diff --git a/src/FileProcessor/TypoScript/Rector/TemplateToFluidTemplateTypoScriptRector.php b/src/FileProcessor/TypoScript/Rector/TemplateToFluidTemplateTypoScriptRector.php new file mode 100644 index 000000000..4e4268560 --- /dev/null +++ b/src/FileProcessor/TypoScript/Rector/TemplateToFluidTemplateTypoScriptRector.php @@ -0,0 +1,50 @@ +value instanceof Scalar) { + return; + } + + if ('TEMPLATE' !== $statement->value->value) { + return; + } + + $statement->value->value = 'FLUIDTEMPLATE'; + } + + public function getRuleDefinition(): RuleDefinition + { + return new RuleDefinition('Convert TEMPLATE to FLUIDTEMPLATE', [ + new CodeSample( + <<<'CODE_SAMPLE' +page.10 = TEMPLATE +CODE_SAMPLE + , + <<<'CODE_SAMPLE' +page.10 = FLUIDTEMPLATE +CODE_SAMPLE + ), + ]); + } +} diff --git a/tests/FileProcessor/TypoScript/Fixture/TypoScript/template_to_fluidtemplate.typoscript b/tests/FileProcessor/TypoScript/Fixture/TypoScript/template_to_fluidtemplate.typoscript new file mode 100644 index 000000000..7d754e9dc --- /dev/null +++ b/tests/FileProcessor/TypoScript/Fixture/TypoScript/template_to_fluidtemplate.typoscript @@ -0,0 +1,3 @@ +page.10 = TEMPLATE +----- +page.10 = FLUIDTEMPLATE diff --git a/tests/FileProcessor/TypoScript/config/configured_rule.php b/tests/FileProcessor/TypoScript/config/configured_rule.php index ee157ebb6..5b702c995 100644 --- a/tests/FileProcessor/TypoScript/config/configured_rule.php +++ b/tests/FileProcessor/TypoScript/config/configured_rule.php @@ -24,6 +24,7 @@ use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\FileIncludeToImportStatementTypoScriptRector; use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\LibFluidContentToLibContentElementRector; use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\OldConditionToExpressionLanguageTypoScriptRector; +use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\TemplateToFluidTemplateTypoScriptRector; return static function (RectorConfig $rectorConfig): void { $rectorConfig->import(__DIR__ . '/../../../../config/config_test.php'); @@ -51,4 +52,5 @@ $rectorConfig->rule(AdditionalHeadersToArrayTypoScriptRector::class); $rectorConfig->rule(LibFluidContentToLibContentElementRector::class); $rectorConfig->rule(LibFluidContentToContentElementTypoScriptPostRector::class); + $rectorConfig->rule(TemplateToFluidTemplateTypoScriptRector::class); };