Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add MigrateItemsIndexedKeysToAssociativeFractor #232

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"ergebnis/composer-normalize": "^2.42",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.0",
"rector/rector": "^1.2.6",
"symplify/easy-coding-standard": "^12.3",
"symplify/monorepo-builder": "^11.2",
"symplify/rule-doc-generator": "12.1.3"
Expand Down
2 changes: 2 additions & 0 deletions packages/typo3-fractor/config/typo3-12.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateEmailFlagToEmailTypeFlexFormFractor;
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateEvalIntAndDouble2ToTypeNumberFlexFormFractor;
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateInternalTypeFolderToTypeFolderFlexFormFractor;
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor;
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateNullFlagFlexFormFractor;
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigratePasswordAndSaltedPasswordToPasswordTypeFlexFormFractor;
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateRenderTypeColorpickerToTypeColorFlexFormFractor;
Expand Down Expand Up @@ -50,4 +51,5 @@
$services->set(RenameConfigXhtmlDoctypeToDoctypeFractor::class);
$services->set(RenameTcemainLinkHandlerMailKeyFractor::class);
$services->set(UseConfigArrayForTSFEPropertiesFractor::class);
$services->set(MigrateItemsIndexedKeysToAssociativeFractor::class);
};
57 changes: 56 additions & 1 deletion packages/typo3-fractor/docs/typo3-fractor-rules.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 24 Rules Overview
# 25 Rules Overview

## AbstractMessageGetSeverityFluidFractor

Expand Down Expand Up @@ -134,6 +134,61 @@ Migrates TCA internal_type into new new TCA type folder

<br>

## MigrateItemsIndexedKeysToAssociativeFractor

Migrates indexed item array keys to associative for type select, radio and check

- class: [`a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor`](../rules/TYPO3v12/FlexForm/MigrateItemsIndexedKeysToAssociativeFractor.php)

```diff
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<sheetTitle>Sheet Title</sheetTitle>
<type>array</type>
<el>
<selectSingleColumn>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="0" type="array">
- <numIndex index="0"/>
- <numIndex index="1"/>
+ <label/>
+ <value/>
</numIndex>
<numIndex index="1" type="array">
- <numIndex index="0">Label 1</numIndex>
- <numIndex index="1">1</numIndex>
+ <label>Label 1</label>
+ <value>1</value>
</numIndex>
<numIndex index="2" type="array">
- <numIndex index="0">Label 2</numIndex>
- <numIndex index="1">2</numIndex>
+ <label>Label 2</label>
+ <value>2</value>
</numIndex>
<numIndex index="3" type="array">
- <numIndex index="0">Label 3</numIndex>
- <numIndex index="1">3</numIndex>
+ <label>Label 3</label>
+ <value>3</value>
</numIndex>
</items>
</config>
</selectSingleColumn>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
```

<br>

## MigrateNullFlagFlexFormFractor

Migrate null flag
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<sheetTitle>sheetTitle</sheetTitle>
<type>array</type>
<el>
<selectSingleColumn>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0"/>
<numIndex index="1"/>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Label 1</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">Label 2</numIndex>
<numIndex index="1">2</numIndex>
</numIndex>
<numIndex index="3" type="array">
<numIndex index="0">Label 3</numIndex>
<numIndex index="1">3</numIndex>
</numIndex>
</items>
</config>
</selectSingleColumn>
<selectCheckBoxColumn>
<config>
<type>select</type>
<renderType>selectCheckBox</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">My label</numIndex>
<numIndex index="1">0</numIndex>
<numIndex index="2">my-icon</numIndex>
<numIndex index="3">group1</numIndex>
<numIndex index="4">My Description</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">My label 1</numIndex>
<numIndex index="1">1</numIndex>
<numIndex index="2">my-icon</numIndex>
<numIndex index="3">group1</numIndex>
<numIndex index="4">My Description</numIndex>
</numIndex>
</items>
</config>
</selectCheckBoxColumn>
<radioColumn>
<config>
<type>radio</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">My label</numIndex>
<numIndex index="1">0</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">My label 1</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">My label 2</numIndex>
<numIndex index="1">2</numIndex>
</numIndex>
</items>
</config>
</radioColumn>
<checkColumn>
<config>
<type>check</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">My label</numIndex>
<invertStateDisplay>1</invertStateDisplay>
</numIndex>
<numIndex index="1" type="array">
<label>My label 2</label>
<invertStateDisplay>1</invertStateDisplay>
</numIndex>
</items>
</config>
</checkColumn>
<alreadyMigratedSelectCheckBox>
<config>
<type>select</type>
<renderType>selectCheckBox</renderType>
<items type="array">
<numIndex index="0">
<label>My label</label>
<value>0</value>
<icon>my-icon</icon>
<group>group1</group>
<description>My Description</description>
</numIndex>
</items>
</config>
</alreadyMigratedSelectCheckBox>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
-----
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<sheetTitle>sheetTitle</sheetTitle>
<type>array</type>
<el>
<selectSingleColumn>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="0" type="array">
<label/>
<value/>
</numIndex>
<numIndex index="1" type="array">
<label>Label 1</label>
<value>1</value>
</numIndex>
<numIndex index="2" type="array">
<label>Label 2</label>
<value>2</value>
</numIndex>
<numIndex index="3" type="array">
<label>Label 3</label>
<value>3</value>
</numIndex>
</items>
</config>
</selectSingleColumn>
<selectCheckBoxColumn>
<config>
<type>select</type>
<renderType>selectCheckBox</renderType>
<items type="array">
<numIndex index="0" type="array">
<label>My label</label>
<value>0</value>
<icon>my-icon</icon>
<group>group1</group>
<description>My Description</description>
</numIndex>
<numIndex index="1" type="array">
<label>My label 1</label>
<value>1</value>
<icon>my-icon</icon>
<group>group1</group>
<description>My Description</description>
</numIndex>
</items>
</config>
</selectCheckBoxColumn>
<radioColumn>
<config>
<type>radio</type>
<items type="array">
<numIndex index="0" type="array">
<label>My label</label>
<value>0</value>
</numIndex>
<numIndex index="1" type="array">
<label>My label 1</label>
<value>1</value>
</numIndex>
<numIndex index="2" type="array">
<label>My label 2</label>
<value>2</value>
</numIndex>
</items>
</config>
</radioColumn>
<checkColumn>
<config>
<type>check</type>
<items type="array">
<numIndex index="0" type="array">
<label>My label</label>
<invertStateDisplay>1</invertStateDisplay>
</numIndex>
<numIndex index="1" type="array">
<label>My label 2</label>
<invertStateDisplay>1</invertStateDisplay>
</numIndex>
</items>
</config>
</checkColumn>
<alreadyMigratedSelectCheckBox>
<config>
<type>select</type>
<renderType>selectCheckBox</renderType>
<items type="array">
<numIndex index="0">
<label>My label</label>
<value>0</value>
<icon>my-icon</icon>
<group>group1</group>
<description>My Description</description>
</numIndex>
</items>
</config>
</alreadyMigratedSelectCheckBox>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace a9f\Typo3Fractor\Tests\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor;

use a9f\Fractor\Testing\PHPUnit\AbstractFractorTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

final class MigrateItemsIndexedKeysToAssociativeFractorTest extends AbstractFractorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): \Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.xml');
}

public function provideConfigFilePath(): ?string
{
return __DIR__ . '/config/fractor.php';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use a9f\Fractor\Configuration\FractorConfiguration;
use a9f\Fractor\ValueObject\Indent;
use a9f\FractorXml\Configuration\XmlProcessorOption;
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor;

return FractorConfiguration::configure()
->withOptions([
XmlProcessorOption::INDENT_CHARACTER => Indent::STYLE_TAB,
XmlProcessorOption::INDENT_SIZE => 1,
])
->withRules([MigrateItemsIndexedKeysToAssociativeFractor::class]);
Loading