-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add template for yaml based rectors
It is now possible to generate yaml rectors
- Loading branch information
1 parent
7f67a36
commit 666dcd9
Showing
9 changed files
with
147 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,6 @@ insert_final_newline = true | |
|
||
[tabs.txt] | ||
indent_style = tab | ||
|
||
[*.yaml.inc] | ||
indent_size = 2 |
1 change: 0 additions & 1 deletion
1
...s/FileProcessor/Yaml/Form/Rector/v10/v0/EmailFinisherRector/Fixture/my_form.form.yaml.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
finishers: | ||
- | ||
options: | ||
|
42 changes: 21 additions & 21 deletions
42
...s/FileProcessor/Yaml/Form/Rector/v10/v0/TranslationFileRector/Fixture/form_setup.yaml.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
TYPO3: | ||
CMS: | ||
Form: | ||
prototypes: | ||
standard: | ||
formElementsDefinition: | ||
Form: | ||
renderingOptions: | ||
translation: | ||
translationFile: | ||
10: 'EXT:form/Resources/Private/Language/locallang.xlf' | ||
20: 'EXT:myextension/Resources/Private/Language/locallang.xlf' | ||
CMS: | ||
Form: | ||
prototypes: | ||
standard: | ||
formElementsDefinition: | ||
Form: | ||
renderingOptions: | ||
translation: | ||
translationFile: | ||
10: 'EXT:form/Resources/Private/Language/locallang.xlf' | ||
20: 'EXT:myextension/Resources/Private/Language/locallang.xlf' | ||
----- | ||
TYPO3: | ||
CMS: | ||
Form: | ||
prototypes: | ||
standard: | ||
formElementsDefinition: | ||
Form: | ||
renderingOptions: | ||
translation: | ||
translationFiles: | ||
20: 'EXT:myextension/Resources/Private/Language/locallang.xlf' | ||
CMS: | ||
Form: | ||
prototypes: | ||
standard: | ||
formElementsDefinition: | ||
Form: | ||
renderingOptions: | ||
translation: | ||
translationFiles: | ||
20: 'EXT:myextension/Resources/Private/Language/locallang.xlf' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
utils/generator/templates/src/Rector/__Major__/__Minor__/yaml/__Name__.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\Rector\__Major__\__Minor__\__Type__; | ||
|
||
use Ssch\TYPO3Rector\Contract\FileProcessor\Yaml\Form\FormYamlRectorInterface; | ||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
|
||
/** | ||
* @changelog __Changelog_Url__ | ||
* @see \Ssch\TYPO3Rector\Tests\Rector\__Major__\__Minor__\__Type__\__Test_Directory__\__Name__Test | ||
*/ | ||
final class __Name__ implements FormYamlRectorInterface | ||
{ | ||
/** | ||
* @param mixed[] $yaml | ||
*/ | ||
public function refactor(array $yaml): array | ||
{ | ||
// Your code here | ||
|
||
return $yaml; | ||
} | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getRuleDefinition(): RuleDefinition | ||
{ | ||
return new RuleDefinition('__Description__', [new CodeSample( | ||
<<<'CODE_SAMPLE' | ||
CODE_SAMPLE | ||
, | ||
<<<'CODE_SAMPLE' | ||
CODE_SAMPLE | ||
)]); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...mplates/tests/Rector/__Major__/__Minor__/yaml/__Test_Directory__/Fixture/fixture.yaml.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
TYPO3: | ||
CMS: | ||
Form: | ||
prototypes: | ||
standard: | ||
finishersDefinition: | ||
EmailToReceiver: | ||
FormEngine: | ||
elements: | ||
recipients: | ||
el: | ||
_arrayContainer: | ||
el: | ||
email: | ||
TCEforms: | ||
label: tt_content.finishersDefinition.EmailToSender.recipients.email.label | ||
config: | ||
type: input | ||
----- | ||
TYPO3: | ||
CMS: | ||
Form: | ||
prototypes: | ||
standard: | ||
finishersDefinition: | ||
EmailToReceiver: | ||
FormEngine: | ||
elements: | ||
recipients: | ||
el: | ||
_arrayContainer: | ||
el: | ||
email: | ||
label: tt_content.finishersDefinition.EmailToSender.recipients.email.label | ||
config: | ||
type: input |
32 changes: 32 additions & 0 deletions
32
...r/templates/tests/Rector/__Major__/__Minor__/yaml/__Test_Directory__/__Name__Test.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\__Major__\__Minor__\__Type__\__Test_Directory__; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class __Name__Test extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<array<string>> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.yaml.inc'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...s/tests/Rector/__Major__/__Minor__/yaml/__Test_Directory__/config/configured_rule.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Ssch\TYPO3Rector\Rector\__Major__\__Minor__\__Type__\__Name__; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->import(__DIR__ . '/../../../../../../../config/config_test.php'); | ||
$rectorConfig->rule(__Name__::class); | ||
}; |