diff --git a/Classes/Form/Transformation/DataTransformerRegistry.php b/Classes/Form/Transformation/DataTransformerRegistry.php index c833e3b0d..7d3ca48c9 100644 --- a/Classes/Form/Transformation/DataTransformerRegistry.php +++ b/Classes/Form/Transformation/DataTransformerRegistry.php @@ -10,6 +10,7 @@ */ use Symfony\Component\DependencyInjection\ServiceLocator; +use TYPO3\CMS\Core\Utility\GeneralUtility; class DataTransformerRegistry { @@ -18,6 +19,8 @@ class DataTransformerRegistry */ private array $transformers = []; + private static array $legacy = []; + public function __construct(ServiceLocator $locator) { /** @var DataTransformerInterface[] $transformers */ @@ -31,6 +34,11 @@ function (DataTransformerInterface $a, DataTransformerInterface $b) { ); } + public static function registerTransformerOnLegacyPhpVersion(string $transformerClassName): void + { + self::$legacy[] = $transformerClassName; + } + public function resolveDataTransformerByType(string $type): DataTransformerInterface { foreach ($this->transformers as $transformer) { @@ -39,6 +47,15 @@ public function resolveDataTransformerByType(string $type): DataTransformerInter } } + /** @var class-string $legacyClassName */ + foreach (self::$legacy as $legacyClassName) { + /** @var DataTransformerInterface $transformer */ + $transformer = GeneralUtility::makeInstance($legacyClassName); + if ($transformer->canTransformToType($type)) { + return $transformer; + } + } + throw new \InvalidArgumentException( 'Flux could not resolve a data transformer for type "' . $type . '"', 1720346755 diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index efe075744..3683f3da8 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -24,6 +24,10 @@ services: arguments: $locator: !tagged_locator { tag: 'flux.datatransformer', index_by: 'identifier' } + # This entry only exists for PHP <8 to be able to load FileTransformer. Don't rely on being able to construct this! + FluidTYPO3\Flux\Form\Transformation\Transformer\FileTransformer: + public: true + FluidTYPO3\Flux\Integration\HookSubscribers\ColumnPositionItems: public: true FluidTYPO3\Flux\Backend\BackendLayoutDataProvider: diff --git a/ext_localconf.php b/ext_localconf.php index 9b3e7124a..8ddbed543 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -44,6 +44,15 @@ $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ($GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] == '' ? '' : ',') . 'tx_fed_page_controller_action,tx_fed_page_controller_action_sub,tx_fed_page_flexform,tx_fed_page_flexform_sub,'; + if (version_compare((string) PHP_MAJOR_VERSION, '8.0', '<')) { + \FluidTYPO3\Flux\Form\Transformation\DataTransformerRegistry::registerTransformerOnLegacyPhpVersion(\FluidTYPO3\Flux\Form\Transformation\Transformer\ArrayTransformer::class); + \FluidTYPO3\Flux\Form\Transformation\DataTransformerRegistry::registerTransformerOnLegacyPhpVersion(\FluidTYPO3\Flux\Form\Transformation\Transformer\BooleanTransformer::class); + \FluidTYPO3\Flux\Form\Transformation\DataTransformerRegistry::registerTransformerOnLegacyPhpVersion(\FluidTYPO3\Flux\Form\Transformation\Transformer\FileTransformer::class); + \FluidTYPO3\Flux\Form\Transformation\DataTransformerRegistry::registerTransformerOnLegacyPhpVersion(\FluidTYPO3\Flux\Form\Transformation\Transformer\FloatTransformer::class); + \FluidTYPO3\Flux\Form\Transformation\DataTransformerRegistry::registerTransformerOnLegacyPhpVersion(\FluidTYPO3\Flux\Form\Transformation\Transformer\FunctionCallTransformer::class); + \FluidTYPO3\Flux\Form\Transformation\DataTransformerRegistry::registerTransformerOnLegacyPhpVersion(\FluidTYPO3\Flux\Form\Transformation\Transformer\IntegerTransformer::class); + \FluidTYPO3\Flux\Form\Transformation\DataTransformerRegistry::registerTransformerOnLegacyPhpVersion(\FluidTYPO3\Flux\Form\Transformation\Transformer\ObjectTransformer::class); + } } $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][\FluidTYPO3\Flux\Updates\MigrateColPosWizard::class]