From d8f11ba1f36193aafa231bd1bacd07d637ca7164 Mon Sep 17 00:00:00 2001 From: Nikita Hovratov Date: Tue, 9 Apr 2024 16:16:05 +0200 Subject: [PATCH] [TASK] Remove TcaPreparation workaround Fixes: #145 --- .../card_group/EditorInterface.yaml | 1 + Classes/FieldType/FileFieldType.php | 3 +- Classes/Generator/TcaGenerator.php | 3 -- Tests/Unit/FieldTypes/FileFieldTypeTest.php | 18 +------- Tests/Unit/Generator/TcaGeneratorTest.php | 42 ------------------- composer.json | 8 ++-- 6 files changed, 7 insertions(+), 68 deletions(-) diff --git a/Build/content-blocks-examples/ContentBlocks/ContentElements/card_group/EditorInterface.yaml b/Build/content-blocks-examples/ContentBlocks/ContentElements/card_group/EditorInterface.yaml index 02467a43..813e4d2a 100644 --- a/Build/content-blocks-examples/ContentBlocks/ContentElements/card_group/EditorInterface.yaml +++ b/Build/content-blocks-examples/ContentBlocks/ContentElements/card_group/EditorInterface.yaml @@ -34,6 +34,7 @@ fields: fields: - identifier: image type: File + allowed: common-image-types - identifier: title type: Text - identifier: bodytext diff --git a/Classes/FieldType/FileFieldType.php b/Classes/FieldType/FileFieldType.php index 176b6668..7542943e 100644 --- a/Classes/FieldType/FileFieldType.php +++ b/Classes/FieldType/FileFieldType.php @@ -17,7 +17,6 @@ namespace TYPO3\CMS\ContentBlocks\FieldType; -use TYPO3\CMS\Core\Preparations\TcaPreparation; use TYPO3\CMS\Core\Resource\AbstractFile; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -80,7 +79,7 @@ public function getTca(): array $tca = $this->toTca(); $config['type'] = self::getTcaType(); if ($this->allowed !== [] && $this->allowed !== '') { - $config['allowed'] = TcaPreparation::prepareFileExtensions($this->allowed); + $config['allowed'] = $this->allowed; } if ($this->disallowed !== [] && $this->disallowed !== '') { $config['disallowed'] = $this->disallowed; diff --git a/Classes/Generator/TcaGenerator.php b/Classes/Generator/TcaGenerator.php index 25edf96a..3b651128 100644 --- a/Classes/Generator/TcaGenerator.php +++ b/Classes/Generator/TcaGenerator.php @@ -37,7 +37,6 @@ use TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory; use TYPO3\CMS\ContentBlocks\Service\SystemExtensionAvailability; use TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent; -use TYPO3\CMS\Core\Preparations\TcaPreparation; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -149,7 +148,6 @@ public function __construct( protected readonly SimpleTcaSchemaFactory $simpleTcaSchemaFactory, protected readonly EventDispatcherInterface $eventDispatcher, protected readonly LanguageFileRegistry $languageFileRegistry, - protected readonly TcaPreparation $tcaPreparation, protected readonly SystemExtensionAvailability $systemExtensionAvailability, protected readonly FlexFormGenerator $flexFormGenerator, ) {} @@ -188,7 +186,6 @@ public function generate(array $baseTca): array foreach ($this->tableDefinitionCollection as $tableDefinition) { $tca[$tableDefinition->getTable()] = $this->generateTableTca($tableDefinition, $baseTca); } - $tca = $this->tcaPreparation->prepare($tca); return $tca; } diff --git a/Tests/Unit/FieldTypes/FileFieldTypeTest.php b/Tests/Unit/FieldTypes/FileFieldTypeTest.php index 5d95d178..4c5bb948 100644 --- a/Tests/Unit/FieldTypes/FileFieldTypeTest.php +++ b/Tests/Unit/FieldTypes/FileFieldTypeTest.php @@ -98,7 +98,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable 'exclude' => true, 'config' => [ 'type' => 'file', - 'allowed' => 'gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai,svg', + 'allowed' => 'common-image-types', 'disallowed' => 'png', 'appearance' => [ 'foo' => 'bar', @@ -194,22 +194,6 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable ], ], ]; - - yield 'allowed and disallowed accept arrays' => [ - 'config' => [ - 'non_available_field' => 'foo', - 'allowed' => ['common-image-types'], - 'disallowed' => ['png'], - ], - 'expectedTca' => [ - 'exclude' => true, - 'config' => [ - 'type' => 'file', - 'allowed' => 'gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai,svg', - 'disallowed' => ['png'], - ], - ], - ]; } #[DataProvider('getTcaReturnsExpectedTcaDataProvider')] diff --git a/Tests/Unit/Generator/TcaGeneratorTest.php b/Tests/Unit/Generator/TcaGeneratorTest.php index 91f5b5a0..645a0415 100644 --- a/Tests/Unit/Generator/TcaGeneratorTest.php +++ b/Tests/Unit/Generator/TcaGeneratorTest.php @@ -34,7 +34,6 @@ use TYPO3\CMS\Core\Cache\Frontend\NullFrontend; use TYPO3\CMS\Core\EventDispatcher\NoopEventDispatcher; use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider; -use TYPO3\CMS\Core\Preparations\TcaPreparation; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class TcaGeneratorTest extends UnitTestCase @@ -472,16 +471,6 @@ public static function checkTcaFieldTypesDataProvider(): iterable 'label' => 'file', 'config' => [ 'type' => 'file', - 'foreign_table' => 'sys_file_reference', - 'foreign_field' => 'uid_foreign', - 'foreign_sortby' => 'sorting_foreign', - 'foreign_table_field' => 'tablenames', - 'foreign_match_fields' => [ - 'fieldname' => 't3ce_example_file', - 'tablenames' => 'tt_content', - ], - 'foreign_label' => 'uid_local', - 'foreign_selector' => 'uid_local', ], 'exclude' => true, ], @@ -489,18 +478,6 @@ public static function checkTcaFieldTypesDataProvider(): iterable 'label' => 'category', 'config' => [ 'type' => 'category', - 'foreign_table' => 'sys_category', - 'size' => 20, - 'foreign_table_where' => ' AND {#sys_category}.{#sys_language_uid} IN (-1, 0)', - 'relationship' => 'manyToMany', - 'maxitems' => 99999, - 'default' => 0, - 'MM' => 'sys_category_record_mm', - 'MM_opposite_field' => 'items', - 'MM_match_fields' => [ - 'tablenames' => 'tt_content', - 'fieldname' => 't3ce_example_category', - ], ], 'exclude' => true, ], @@ -957,19 +934,6 @@ public static function checkTcaFieldTypesDataProvider(): iterable ], ], ], - 'sys_category' => [ - 'columns' => [ - 'items' => [ - 'config' => [ - 'MM_oppositeUsage' => [ - 'tt_content' => [ - 't3ce_example_category', - ], - ], - ], - ], - ], - ], ], ]; @@ -2144,7 +2108,6 @@ public function checkTcaFieldTypes(array $contentBlocks, array $expected): void $simpleTcaSchemaFactory, new NoopEventDispatcher(), $languageFileRegistry, - new TcaPreparation(), $systemExtensionAvailability, $flexFormGenerator, ); @@ -2329,7 +2292,6 @@ public function pageTypesGenerateCorrectTca(array $contentBlocks, bool $seoExten $simpleTcaSchemaFactory, new NoopEventDispatcher(), $languageFileRegistry, - new TcaPreparation(), $systemExtensionAvailability, $flexFormGenerator, ); @@ -2371,7 +2333,6 @@ public function missingLabelFieldThrowsException(): void $simpleTcaSchemaFactory, new NoopEventDispatcher(), $languageFileRegistry, - new TcaPreparation(), $systemExtensionAvailability, $flexFormGenerator, ); @@ -3039,7 +3000,6 @@ public function checkFlexFormTca(array $contentBlocks, array $expected): void $simpleTcaSchemaFactory, new NoopEventDispatcher(), $languageFileRegistry, - new TcaPreparation(), $systemExtensionAvailability, $flexFormGenerator, ); @@ -3093,7 +3053,6 @@ public function displayCondIsPrefixedForStringSyntax(): void $simpleTcaSchemaFactory, new NoopEventDispatcher(), $languageFileRegistry, - new TcaPreparation(), $systemExtensionAvailability, $flexFormGenerator, ); @@ -3318,7 +3277,6 @@ public function existingTablesCanBeExtendedWithAdditionalType(): void $simpleTcaSchemaFactory, new NoopEventDispatcher(), $languageFileRegistry, - new TcaPreparation(), $systemExtensionAvailability, $flexFormGenerator, ); diff --git a/composer.json b/composer.json index 4a8fde9f..958a588c 100644 --- a/composer.json +++ b/composer.json @@ -36,10 +36,10 @@ }, "require": { "symfony/var-exporter": "^6.4 || ^7.0", - "typo3/cms-backend": "^12.4.11", - "typo3/cms-core": "^12.4.11", - "typo3/cms-fluid": "^12.4.11", - "typo3/cms-frontend": "^12.4.11" + "typo3/cms-backend": "^12.4.14", + "typo3/cms-core": "^12.4.14", + "typo3/cms-fluid": "^12.4.14", + "typo3/cms-frontend": "^12.4.14" }, "replace": { "typo3/cms-content-blocks": "*"