diff --git a/src/FileProcessor/FlexForms/Rector/v7/v6/RenderTypeFlexFormRector.php b/src/FileProcessor/FlexForms/Rector/v7/v6/RenderTypeFlexFormRector.php index 8eda81dec..f40b31ca4 100644 --- a/src/FileProcessor/FlexForms/Rector/v7/v6/RenderTypeFlexFormRector.php +++ b/src/FileProcessor/FlexForms/Rector/v7/v6/RenderTypeFlexFormRector.php @@ -90,16 +90,16 @@ protected function refactorColumn(?DOMElement $configElement): void if ($renderModeDomElement instanceof DOMElement) { $renderMode = $renderModeDomElement->nodeValue; switch ($renderMode) { - case 'tree' : + case 'tree': $renderTypeName = 'selectTree'; break; - case 'singlebox' : + case 'singlebox': $renderTypeName = 'selectSingleBox'; break; - case 'checkbox' : + case 'checkbox': $renderTypeName = 'selectCheckBox'; break; - default : + default: $renderTypeName = null; } diff --git a/src/FileProcessor/TypoScript/Conditions/GlobalVarConditionMatcher.php b/src/FileProcessor/TypoScript/Conditions/GlobalVarConditionMatcher.php index ef9130cbe..03f0831c2 100644 --- a/src/FileProcessor/TypoScript/Conditions/GlobalVarConditionMatcher.php +++ b/src/FileProcessor/TypoScript/Conditions/GlobalVarConditionMatcher.php @@ -53,34 +53,34 @@ public function change(string $condition): ?string } switch ($type) { - case 'TSFE' : + case 'TSFE': $conditions[$key][] = $this->refactorTsfe($property, $operator, $value); break; - case 'GP' : + case 'GP': $conditions[$key][] = $this->refactorGetPost($property, $operator, $value); break; - case 'LIT' : + case 'LIT': $conditions[$key][] = sprintf('"%s" %s "%s"', $value, self::OPERATOR_MAPPING[$operator], $property); break; - case 'ENV' : + case 'ENV': $conditions[$key][] = $this->createEnvCondition($property, $operator, $value); break; - case 'IENV' : + case 'IENV': $conditions[$key][] = $this->createIndependentCondition($property, $operator, $value); break; - case 'BE_USER' : + case 'BE_USER': $conditions[$key][] = $this->createBackendUserCondition($property, $operator, $value); break; - case '_GET' : + case '_GET': $conditions[$key][] = $this->refactorGet($property, $operator, $value); break; - case 'GPmerged' : + case 'GPmerged': $conditions[$key][] = $this->refactorGetPost($property, $operator, $value); break; - case '_POST' : + case '_POST': $conditions[$key][] = $this->refactorPost($property, $operator, $value); break; - default : + default: $conditions[$key][] = $condition; break; } diff --git a/src/Helper/FlexFormHelperTrait.php b/src/Helper/FlexFormHelperTrait.php index b8934d5ca..0835963b0 100644 --- a/src/Helper/FlexFormHelperTrait.php +++ b/src/Helper/FlexFormHelperTrait.php @@ -21,7 +21,7 @@ protected function extractDomElementByKey(?DOMElement $element, string $key): ?D continue; } - $itemKey = (string) $childNode->nodeName; + $itemKey = $childNode->nodeName; if ($key === $itemKey) { return $childNode; } diff --git a/src/Helper/TcaHelperTrait.php b/src/Helper/TcaHelperTrait.php index d458208b2..8f3c8d1c9 100644 --- a/src/Helper/TcaHelperTrait.php +++ b/src/Helper/TcaHelperTrait.php @@ -172,6 +172,12 @@ private function hasRenderType(Array_ $columnItemConfigurationArray): bool return $renderTypeItem !== null; } + private function hasInternalType(Array_ $columnItemConfigurationArray): bool + { + $internalType = $this->extractArrayItemByKey($columnItemConfigurationArray, 'internal_type'); + return $internalType !== null; + } + private function extractColumns(Return_ $return): ?ArrayItem { return $this->extractArrayItemByKey($return->expr, 'columns'); diff --git a/src/Rector/v12/v0/tca/MigrateInternalTypeFolderToTypeFolderRector.php b/src/Rector/v12/v0/tca/MigrateInternalTypeFolderToTypeFolderRector.php index 6e5acccbe..b396a7163 100644 --- a/src/Rector/v12/v0/tca/MigrateInternalTypeFolderToTypeFolderRector.php +++ b/src/Rector/v12/v0/tca/MigrateInternalTypeFolderToTypeFolderRector.php @@ -37,6 +37,12 @@ public function getRuleDefinition(): RuleDefinition 'internal_type' => 'folder', ], ], + 'bColumn' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'db', + ], + ], ], ], ]; @@ -51,6 +57,11 @@ public function getRuleDefinition(): RuleDefinition 'type' => 'folder', ], ], + 'bColumn' => [ + 'config' => [ + 'type' => 'group', + ], + ], ], ], ]; @@ -65,16 +76,26 @@ protected function refactorColumn(Expr $columnName, Expr $columnTca): void return; } - if (! $this->configIsOfInternalType($configArray, 'folder')) { + if (! $this->isConfigType($configArray, 'group') || ! $this->hasInternalType($configArray)) { + return; + } + + $internalTypeArrayItem = $this->extractArrayItemByKey($configArray, 'internal_type'); + if (! $internalTypeArrayItem instanceof ArrayItem) { + return; + } + + $internalTypeValue = $this->valueResolver->getValue($internalTypeArrayItem->value); + + if (! is_string($internalTypeValue)) { return; } - $toRemoveArrayItem = $this->extractArrayItemByKey($configArray, 'internal_type'); - if ($toRemoveArrayItem instanceof ArrayItem) { - $this->removeNode($toRemoveArrayItem); + if ($internalTypeValue === 'folder') { + $this->changeTcaType($configArray, 'folder'); } - $this->changeTcaType($configArray, 'folder'); + $this->removeNode($internalTypeArrayItem); $this->hasAstBeenChanged = true; } diff --git a/tests/Rector/v12/v0/tca/MigrateInternalTypeRector/Fixture/fixture.php.inc b/tests/Rector/v12/v0/tca/MigrateInternalTypeRector/Fixture/fixture.php.inc index 9c10c8ba6..025c33ffc 100644 --- a/tests/Rector/v12/v0/tca/MigrateInternalTypeRector/Fixture/fixture.php.inc +++ b/tests/Rector/v12/v0/tca/MigrateInternalTypeRector/Fixture/fixture.php.inc @@ -9,6 +9,14 @@ return [ 'config' => [ 'type' => 'group', 'internal_type' => 'folder', + 'maxitems' => 2, + ], + ], + 'bColumn' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'db', + 'minitems' => 2, ], ], ], @@ -26,6 +34,13 @@ return [ 'aColumn' => [ 'config' => [ 'type' => 'folder', + 'maxitems' => 2, + ], + ], + 'bColumn' => [ + 'config' => [ + 'type' => 'group', + 'minitems' => 2, ], ], ],