Skip to content

Commit

Permalink
[TASK] Improve nesting of TranslationFileRector
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Dec 3, 2023
1 parent e04e26e commit eec9846
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,24 @@ public function refactor(array $yaml): array

/**
* @param mixed[] $yaml
*
* @return mixed[]
* @see https://github.com/TYPO3/typo3/blob/10.4/typo3/sysext/form/Classes/Controller/FormEditorController.php#L653-L689
*/
private function refactorTranslationFile(array &$yaml): array
{
foreach ($yaml as &$section) {
if (is_array($section)) {
if (array_key_exists(self::TRANSLATION_FILE_KEY, $section) && is_array(
$section[self::TRANSLATION_FILE_KEY]
)) {
$section['translationFiles'] = $this->buildNewTranslations($section[self::TRANSLATION_FILE_KEY]);
unset($section[self::TRANSLATION_FILE_KEY]);
}
if (! is_array($section)) {
continue;
}

$this->refactorTranslationFile($section);
if (array_key_exists(self::TRANSLATION_FILE_KEY, $section)
&& is_array($section[self::TRANSLATION_FILE_KEY])
) {
$section['translationFiles'] = $this->buildNewTranslations($section[self::TRANSLATION_FILE_KEY]);
unset($section[self::TRANSLATION_FILE_KEY]);
}

$this->refactorTranslationFile($section);
}

unset($section);
Expand Down

0 comments on commit eec9846

Please sign in to comment.