diff --git a/Classes/Builder/ContentBlockBuilder.php b/Classes/Builder/ContentBlockBuilder.php index 559c1449..f390387c 100644 --- a/Classes/Builder/ContentBlockBuilder.php +++ b/Classes/Builder/ContentBlockBuilder.php @@ -20,6 +20,7 @@ use Symfony\Component\Yaml\Yaml; use TYPO3\CMS\ContentBlocks\Definition\ContentType\ContentType; use TYPO3\CMS\ContentBlocks\Definition\Factory\TableDefinitionCollectionFactory; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeRegistry; use TYPO3\CMS\ContentBlocks\Generator\HtmlTemplateCodeGenerator; use TYPO3\CMS\ContentBlocks\Generator\LanguageFileGenerator; use TYPO3\CMS\ContentBlocks\Loader\LoadedContentBlock; @@ -38,6 +39,7 @@ public function __construct( protected readonly HtmlTemplateCodeGenerator $htmlTemplateCodeGenerator, protected readonly LanguageFileGenerator $languageFileGenerator, protected readonly ContentBlockRegistry $contentBlockRegistry, + protected readonly FieldTypeRegistry $fieldTypeRegistry, protected readonly TableDefinitionCollectionFactory $tableDefinitionCollectionFactory, protected readonly SimpleTcaSchemaFactory $simpleTcaSchemaFactory, ) {} @@ -87,6 +89,7 @@ protected function initializeRegistries(LoadedContentBlock $contentBlock): void $this->contentBlockRegistry->register($contentBlock); $tableDefinitionCollection = $this->tableDefinitionCollectionFactory->createUncached( $this->contentBlockRegistry, + $this->fieldTypeRegistry, $this->simpleTcaSchemaFactory, ); $automaticLanguageKeysRegistry = $tableDefinitionCollection->getAutomaticLanguageKeysRegistry(); diff --git a/Classes/DataProcessing/ContentBlockDataDecorator.php b/Classes/DataProcessing/ContentBlockDataDecorator.php index 7339fba0..4899b356 100644 --- a/Classes/DataProcessing/ContentBlockDataDecorator.php +++ b/Classes/DataProcessing/ContentBlockDataDecorator.php @@ -22,7 +22,7 @@ use TYPO3\CMS\ContentBlocks\Definition\TableDefinition; use TYPO3\CMS\ContentBlocks\Definition\TableDefinitionCollection; use TYPO3\CMS\ContentBlocks\Definition\TcaFieldDefinition; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldType; use TYPO3\CMS\ContentBlocks\Schema\Exception\UndefinedFieldException; use TYPO3\CMS\ContentBlocks\Schema\Exception\UndefinedSchemaException; use TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory; @@ -72,8 +72,7 @@ private function buildContentBlockDataObjectRecursive( $grids = []; foreach ($contentTypeDefinition->getColumns() as $column) { $tcaFieldDefinition = $tableDefinition->getTcaFieldDefinitionCollection()->getField($column); - $fieldType = $tcaFieldDefinition->getFieldType(); - if (!$fieldType->isRenderable()) { + if (!$tcaFieldDefinition->getFieldType()->isRenderable()) { continue; } $resolvedField = $resolvedRelation->resolved[$tcaFieldDefinition->getUniqueIdentifier()]; @@ -111,7 +110,9 @@ private function handleRelation( ?PageLayoutContext $context = null, ): mixed { $resolvedField = $resolvedRelation->resolved[$tcaFieldDefinition->getUniqueIdentifier()]; - $resolvedField = match ($tcaFieldDefinition->getFieldType()) { + $fieldTypeName = $tcaFieldDefinition->getFieldType()->getName(); + $fieldTypeEnum = FieldType::tryFrom($fieldTypeName); + $resolvedField = match ($fieldTypeEnum) { FieldType::COLLECTION, FieldType::RELATION => $this->transformMultipleRelation( $resolvedField, diff --git a/Classes/DataProcessing/RelationResolver.php b/Classes/DataProcessing/RelationResolver.php index 3725ee01..c6f3992c 100644 --- a/Classes/DataProcessing/RelationResolver.php +++ b/Classes/DataProcessing/RelationResolver.php @@ -23,8 +23,8 @@ use TYPO3\CMS\ContentBlocks\Definition\TableDefinition; use TYPO3\CMS\ContentBlocks\Definition\TableDefinitionCollection; use TYPO3\CMS\ContentBlocks\Definition\TcaFieldDefinition; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FolderFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FolderFieldType; use TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\RelationHandler; @@ -80,7 +80,8 @@ public function processField( array $record, string $table ): mixed { - $fieldType = $tcaFieldDefinition->getFieldType(); + $fieldTypeName = $tcaFieldDefinition->getFieldType()->getName(); + $fieldTypeEnum = FieldType::tryFrom($fieldTypeName); $recordIdentifier = $tcaFieldDefinition->getUniqueIdentifier(); if (!array_key_exists($recordIdentifier, $record)) { throw new \RuntimeException( @@ -90,35 +91,35 @@ public function processField( ); } $data = $record[$recordIdentifier]; - if ($fieldType === FieldType::FILE) { + if ($fieldTypeEnum === FieldType::FILE) { $fileCollector = GeneralUtility::makeInstance(FileCollector::class); $fileCollector->addFilesFromRelation($table, $recordIdentifier, $record); return $fileCollector->getFiles(); } - if ($fieldType === FieldType::COLLECTION) { + if ($fieldTypeEnum === FieldType::COLLECTION) { return $this->processCollection($table, $record, $tcaFieldDefinition, $typeDefinition); } - if ($fieldType === FieldType::CATEGORY) { + if ($fieldTypeEnum === FieldType::CATEGORY) { return $this->processCategory($tcaFieldDefinition, $typeDefinition, $table, $record); } - if ($fieldType === FieldType::RELATION) { + if ($fieldTypeEnum === FieldType::RELATION) { return $this->processRelation($tcaFieldDefinition, $typeDefinition, $table, $record); } - if ($fieldType === FieldType::FOLDER) { + if ($fieldTypeEnum === FieldType::FOLDER) { $fileCollector = GeneralUtility::makeInstance(FileCollector::class); $folders = GeneralUtility::trimExplode(',', (string)$data, true); - /** @var FolderFieldConfiguration $folderFieldConfiguration */ - $folderFieldConfiguration = $tcaFieldDefinition->getFieldConfiguration(); - $fileCollector->addFilesFromFolders($folders, $folderFieldConfiguration->isRecursive()); + /** @var FolderFieldType $folderFieldType */ + $folderFieldType = $tcaFieldDefinition->getFieldType(); + $fileCollector->addFilesFromFolders($folders, $folderFieldType->isRecursive()); return $fileCollector->getFiles(); } - if ($fieldType === FieldType::SELECT) { + if ($fieldTypeEnum === FieldType::SELECT) { return $this->processSelect($tcaFieldDefinition, $typeDefinition, $table, $record); } - if ($fieldType === FieldType::FLEXFORM) { + if ($fieldTypeEnum === FieldType::FLEXFORM) { return $this->flexFormService->convertFlexFormContentToArray($data); } - if ($fieldType === FieldType::JSON) { + if ($fieldTypeEnum === FieldType::JSON) { $platform = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable($table) ->getDatabasePlatform(); diff --git a/Classes/Definition/Factory/ContentBlockCompiler.php b/Classes/Definition/Factory/ContentBlockCompiler.php index 26924f61..aabdadaf 100644 --- a/Classes/Definition/Factory/ContentBlockCompiler.php +++ b/Classes/Definition/Factory/ContentBlockCompiler.php @@ -29,7 +29,9 @@ use TYPO3\CMS\ContentBlocks\Definition\TCA\LinebreakDefinition; use TYPO3\CMS\ContentBlocks\Definition\TCA\TabDefinition; use TYPO3\CMS\ContentBlocks\Definition\TcaFieldDefinition; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeInterface; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeRegistry; use TYPO3\CMS\ContentBlocks\Loader\LoadedContentBlock; use TYPO3\CMS\ContentBlocks\Registry\AutomaticLanguageKeysRegistry; use TYPO3\CMS\ContentBlocks\Registry\AutomaticLanguageSource; @@ -72,6 +74,7 @@ final class ContentBlockCompiler { private AutomaticLanguageKeysRegistry $automaticLanguageKeysRegistry; private SimpleTcaSchemaFactory $simpleTcaSchemaFactory; + private FieldTypeRegistry $fieldTypeRegistry; /** * This property tracks Collection foreign_table parent references. @@ -87,9 +90,13 @@ final class ContentBlockCompiler */ private array $typeFieldPerTable = []; - public function compile(ContentBlockRegistry $contentBlockRegistry, SimpleTcaSchemaFactory $simpleTcaSchemaFactory): CompilationResult - { + public function compile( + ContentBlockRegistry $contentBlockRegistry, + FieldTypeRegistry $fieldTypeRegistry, + SimpleTcaSchemaFactory $simpleTcaSchemaFactory + ): CompilationResult { $this->simpleTcaSchemaFactory = $simpleTcaSchemaFactory; + $this->fieldTypeRegistry = $fieldTypeRegistry; $this->automaticLanguageKeysRegistry = new AutomaticLanguageKeysRegistry(); $tableDefinitionList = []; foreach ($contentBlockRegistry->getAll() as $contentBlock) { @@ -127,6 +134,7 @@ private function resetState(): void $this->typeFieldPerTable = []; unset($this->automaticLanguageKeysRegistry); unset($this->simpleTcaSchemaFactory); + unset($this->fieldTypeRegistry); } private function mergeProcessingResult(array $tableDefinitionList): array @@ -160,16 +168,18 @@ private function processFields(ProcessingInput $input, ProcessedFieldsResult $re { foreach ($fields as $field) { $this->initializeField($input, $result, $field); + $fieldTypeName = $result->fieldType::getName(); + $fieldTypeEnum = FieldType::tryFrom($fieldTypeName); $input->languagePath->addPathSegment($result->identifier); $field = $this->initializeFieldLabelAndDescription($input, $result, $field); - if ($result->fieldType === FieldType::FLEXFORM) { + if ($fieldTypeEnum === FieldType::FLEXFORM) { $field = $this->processFlexForm($input, $field); } if ($result->fieldType->hasItems()) { $field = $this->collectItemLabels($input, $result, $field); } $result->tcaFieldDefinition = $this->buildTcaFieldDefinitionArray($input, $result, $field); - if ($result->fieldType === FieldType::COLLECTION) { + if ($fieldTypeEnum === FieldType::COLLECTION) { $this->processCollection($input, $result, $field); } $this->collectProcessedField($result); @@ -252,11 +262,12 @@ private function initializeFieldLabelAndDescription(ProcessingInput $input, Proc private function collectItemLabels(ProcessingInput $input, ProcessedFieldsResult $result, array $field): array { $items = $field['items'] ?? []; - $fieldType = $result->fieldType; + $fieldTypeName = $result->fieldType::getName(); + $fieldTypeEnum = FieldType::tryFrom($fieldTypeName); foreach ($items as $index => $item) { $label = (string)($item['label'] ?? ''); $currentPath = $input->languagePath->getCurrentPath(); - if ($fieldType === FieldType::CHECKBOX) { + if ($fieldTypeEnum === FieldType::CHECKBOX) { $labelPath = $currentPath . '.items.' . $index . '.label'; } else { $value = (string)($item['value'] ?? ''); @@ -367,8 +378,11 @@ private function prependPagesTitlePalette(array $yamlFields): array private function handleRootField(array $rootField, ProcessingInput $input, ProcessedFieldsResult $result): array { $rootFieldType = $this->resolveType($input, $rootField); - $this->assertNoLinebreakOutsideOfPalette($rootFieldType, $input->contentBlock); - $fields = match ($rootFieldType) { + $fieldTypeEnum = FieldType::tryFrom($rootFieldType::getName()); + if ($fieldTypeEnum !== null) { + $this->assertNoLinebreakOutsideOfPalette($fieldTypeEnum, $input->contentBlock); + } + $fields = match ($fieldTypeEnum) { Fieldtype::PALETTE => $this->handlePalette($input, $result, $rootField), FieldType::TAB => $this->handleTab($input, $result, $rootField), default => $this->handleDefault($input, $result, $rootField) @@ -395,11 +409,14 @@ private function handlePalette(ProcessingInput $input, ProcessedFieldsResult $re $paletteItems = []; foreach ($rootPalette['fields'] as $paletteField) { $paletteFieldType = $this->resolveType($input, $paletteField); - if ($paletteFieldType === FieldType::LINEBREAK) { + $fieldTypeEnum = FieldType::tryFrom($paletteFieldType::getName()); + if ($fieldTypeEnum === FieldType::LINEBREAK) { $paletteItems[] = new LinebreakDefinition(); } else { - $this->assertNoPaletteInPalette($paletteFieldType, $paletteField['identifier'], $rootPaletteIdentifier, $input->contentBlock); - $this->assertNoTabInPalette($paletteFieldType, $paletteField['identifier'], $rootPaletteIdentifier, $input->contentBlock); + if ($fieldTypeEnum !== null) { + $this->assertNoPaletteInPalette($fieldTypeEnum, $paletteField['identifier'], $rootPaletteIdentifier, $input->contentBlock); + $this->assertNoTabInPalette($fieldTypeEnum, $paletteField['identifier'], $rootPaletteIdentifier, $input->contentBlock); + } $fields[] = $paletteField; $paletteItems[] = $this->chooseIdentifier($input, $paletteField); } @@ -615,7 +632,7 @@ private function resolveFlexFormField(ProcessingInput $input, array $flexFormFie $flexFormFieldArray = [ 'uniqueIdentifier' => $identifier, 'config' => $flexFormField, - 'type' => FieldType::from($flexFormField['type']), + 'type' => $this->fieldTypeRegistry->get($flexFormField['type']), 'labelPath' => $labelPath, 'descriptionPath' => $descriptionPath, ]; @@ -803,7 +820,7 @@ private function getPrefixType(LoadedContentBlock $contentBlock, array $fieldCon return $contentBlock->getPrefixType(); } - private function resolveType(ProcessingInput $input, array $field): FieldType + private function resolveType(ProcessingInput $input, array $field): FieldTypeInterface { $isExistingField = $this->isExistingField($field); if ($isExistingField) { @@ -813,16 +830,15 @@ private function resolveType(ProcessingInput $input, array $field): FieldType if ($this->simpleTcaSchemaFactory->has($input->table)) { $tcaSchema = $this->simpleTcaSchemaFactory->get($input->table); if ($tcaSchema->hasField($identifier)) { - $tcaField = $tcaSchema->getField($identifier); - $fieldType = $tcaField->getType(); - return $fieldType; + $fieldType = $tcaSchema->getField($identifier); + return $fieldType->getType(); } } } $this->assertTypeExists($field, $input); - $fieldType = FieldType::tryFrom($field['type']); - if ($fieldType === null) { - $validTypesList = array_map(fn(FieldType $fieldType) => $fieldType->value, FieldType::cases()); + $fieldTypeName = $field['type']; + if (!$this->fieldTypeRegistry->has($fieldTypeName)) { + $validTypesList = array_map(fn(FieldTypeInterface $fieldType) => $fieldType::getName(), $this->fieldTypeRegistry->getAll()); sort($validTypesList); $validTypes = implode(', ', $validTypesList); throw new \InvalidArgumentException( @@ -830,7 +846,9 @@ private function resolveType(ProcessingInput $input, array $field): FieldType 1697625849 ); } - if ($fieldType !== FieldType::LINEBREAK) { + $fieldType = $this->fieldTypeRegistry->get($fieldTypeName); + $fieldTypeEnum = FieldType::tryFrom($fieldType::getName()); + if ($fieldTypeEnum !== FieldType::LINEBREAK) { $this->assertIdentifierExists($field, $input); } return $fieldType; @@ -979,10 +997,9 @@ private function validateFlexFormContainsValidFieldTypes(array $field, LoadedCon ); } foreach ($container['fields'] as $containerField) { - $containerType = FieldType::from($containerField['type']); - if (!FieldType::isValidFlexFormField($containerType)) { + if ($this->fieldTypeRegistry->has($containerField['type']) || !FieldType::isValidFlexFormField($this->fieldTypeRegistry->get($containerField['type']))) { throw new \InvalidArgumentException( - 'FlexForm field "' . $field['identifier'] . '" has an invalid field of type "' . $containerType->value . '" inside of a "container" item. Please use valid field types in Content Block "' . $contentBlock->getName() . '".', + 'FlexForm field "' . $field['identifier'] . '" has an invalid field of type "' . $containerField['type'] . '" inside of a "container" item. Please use valid field types in Content Block "' . $contentBlock->getName() . '".', 1686330594 ); } @@ -990,10 +1007,9 @@ private function validateFlexFormContainsValidFieldTypes(array $field, LoadedCon } continue; } - $type = FieldType::from($flexField['type']); - if (!FieldType::isValidFlexFormField($type)) { + if (!$this->fieldTypeRegistry->has($flexField['type']) || !FieldType::isValidFlexFormField($this->fieldTypeRegistry->get($flexField['type']))) { throw new \InvalidArgumentException( - 'Field type "' . $type->value . '" with identifier "' . $flexField['identifier'] . '" is not allowed inside FlexForm in Content Block "' . $contentBlock->getName() . '".', + 'Field type "' . $flexField['type'] . '" with identifier "' . $flexField['identifier'] . '" is not allowed inside FlexForm in Content Block "' . $contentBlock->getName() . '".', 1685220309 ); } diff --git a/Classes/Definition/Factory/Processing/ProcessedFieldsResult.php b/Classes/Definition/Factory/Processing/ProcessedFieldsResult.php index 1e3f5887..6ce32605 100644 --- a/Classes/Definition/Factory/Processing/ProcessedFieldsResult.php +++ b/Classes/Definition/Factory/Processing/ProcessedFieldsResult.php @@ -17,7 +17,7 @@ namespace TYPO3\CMS\ContentBlocks\Definition\Factory\Processing; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeInterface; /** * @internal Not part of TYPO3's public API. @@ -39,7 +39,7 @@ final class ProcessedFieldsResult // Below are temporary properties for the scope of a root field. public string $identifier; public string $uniqueIdentifier; - public FieldType $fieldType; + public FieldTypeInterface $fieldType; public array $tcaFieldDefinition; public function __construct(ProcessingInput $input) diff --git a/Classes/Definition/Factory/TableDefinitionCollectionFactory.php b/Classes/Definition/Factory/TableDefinitionCollectionFactory.php index 1c1e33d4..c63adc37 100644 --- a/Classes/Definition/Factory/TableDefinitionCollectionFactory.php +++ b/Classes/Definition/Factory/TableDefinitionCollectionFactory.php @@ -23,6 +23,7 @@ use TYPO3\CMS\ContentBlocks\Definition\TableDefinition; use TYPO3\CMS\ContentBlocks\Definition\TableDefinitionCollection; use TYPO3\CMS\ContentBlocks\Definition\TcaFieldDefinitionCollection; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeRegistry; use TYPO3\CMS\ContentBlocks\Registry\ContentBlockRegistry; use TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory; use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend; @@ -39,11 +40,15 @@ public function __construct( protected readonly ContentBlockCompiler $contentBlockCompiler, ) {} - public function create(ContentBlockRegistry $contentBlockRegistry, SimpleTcaSchemaFactory $simpleTcaSchemaFactory): TableDefinitionCollection - { + public function create( + ContentBlockRegistry $contentBlockRegistry, + FieldTypeRegistry $fieldTypeRegistry, + SimpleTcaSchemaFactory $simpleTcaSchemaFactory, + ): TableDefinitionCollection { if (!$this->cache->isLazyObjectInitialized()) { $this->tableDefinitionCollection = $this->tableDefinitionCollection ?? $this->createUncached( $contentBlockRegistry, + $fieldTypeRegistry, $simpleTcaSchemaFactory ); return $this->tableDefinitionCollection; @@ -54,6 +59,7 @@ public function create(ContentBlockRegistry $contentBlockRegistry, SimpleTcaSche } $this->tableDefinitionCollection = $this->tableDefinitionCollection ?? $this->createUncached( $contentBlockRegistry, + $fieldTypeRegistry, $simpleTcaSchemaFactory ); $this->setCache(); @@ -68,9 +74,12 @@ public function initializeCache(): void } } - public function createUncached(ContentBlockRegistry $contentBlockRegistry, SimpleTcaSchemaFactory $simpleTcaSchemaFactory): TableDefinitionCollection - { - $compiledContentBlocks = $this->contentBlockCompiler->compile($contentBlockRegistry, $simpleTcaSchemaFactory); + public function createUncached( + ContentBlockRegistry $contentBlockRegistry, + FieldTypeRegistry $fieldTypeRegistry, + SimpleTcaSchemaFactory $simpleTcaSchemaFactory + ): TableDefinitionCollection { + $compiledContentBlocks = $this->contentBlockCompiler->compile($contentBlockRegistry, $fieldTypeRegistry, $simpleTcaSchemaFactory); $tableDefinitionCollection = $this->enrichTableDefinitions($compiledContentBlocks); return $tableDefinitionCollection; } diff --git a/Classes/Definition/SqlColumnDefinition.php b/Classes/Definition/SqlColumnDefinition.php index e45fcb42..c5e21e0f 100644 --- a/Classes/Definition/SqlColumnDefinition.php +++ b/Classes/Definition/SqlColumnDefinition.php @@ -17,8 +17,7 @@ namespace TYPO3\CMS\ContentBlocks\Definition; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldConfigurationInterface; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeInterface; /** * @internal Not part of TYPO3's public API. @@ -26,7 +25,7 @@ final class SqlColumnDefinition { private string $column = ''; - private FieldConfigurationInterface $fieldConfiguration; + private FieldTypeInterface $fieldType; public function __construct(array $columnDefinition) { @@ -35,8 +34,9 @@ public function __construct(array $columnDefinition) } $this->column = $columnDefinition['uniqueIdentifier']; - $this->fieldConfiguration = FieldType::from($columnDefinition['config']['type']) - ->getFieldConfiguration($columnDefinition['config']); + /** @var FieldTypeInterface $fieldType */ + $fieldType = $columnDefinition['type']; + $this->fieldType = $fieldType::createFromArray($columnDefinition['config']); } public function getColumn(): string @@ -46,11 +46,6 @@ public function getColumn(): string public function getSql(): string { - return $this->fieldConfiguration->getSql($this->column); - } - - public function getFieldType(): FieldType - { - return $this->fieldConfiguration->getFieldType(); + return $this->fieldType->getSql($this->column); } } diff --git a/Classes/Definition/TcaFieldDefinition.php b/Classes/Definition/TcaFieldDefinition.php index 26d23017..5c882866 100644 --- a/Classes/Definition/TcaFieldDefinition.php +++ b/Classes/Definition/TcaFieldDefinition.php @@ -18,8 +18,7 @@ namespace TYPO3\CMS\ContentBlocks\Definition; use TYPO3\CMS\ContentBlocks\Definition\ContentType\ContentType; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldConfigurationInterface; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeInterface; /** * @internal Not part of TYPO3's public API. @@ -32,7 +31,7 @@ final class TcaFieldDefinition private string $labelPath = ''; private string $descriptionPath = ''; private bool $useExistingField = false; - private ?FieldConfigurationInterface $fieldConfiguration = null; + private ?FieldTypeInterface $fieldType = null; public static function createFromArray(array $array): TcaFieldDefinition { @@ -40,7 +39,9 @@ public static function createFromArray(array $array): TcaFieldDefinition if ($uniqueIdentifier === '') { throw new \InvalidArgumentException('The identifier for a TcaFieldDefinition must not be empty.', 1629277138); } - if (!($array['type'] ?? null) instanceof FieldType) { + /** @var FieldTypeInterface|null $fieldType */ + $fieldType = $array['type'] ?? null; + if ($fieldType === null) { throw new \InvalidArgumentException('The type in the config for a TcaFieldDefinition must not be empty.', 1629277139); } @@ -52,12 +53,7 @@ public static function createFromArray(array $array): TcaFieldDefinition ->withLabelPath($array['labelPath'] ?? '') ->withDescriptionPath($array['descriptionPath'] ?? '') ->withUseExistingField($array['config']['useExistingField'] ?? false) - ->withFieldConfiguration($array['type']->getFieldConfiguration($array['config'])); - } - - public function getFieldType(): FieldType - { - return $this->fieldConfiguration->getFieldType(); + ->withFieldType($fieldType::createFromArray($array['config'])); } public function getUniqueIdentifier(): string @@ -92,15 +88,15 @@ public function useExistingField(): bool public function getTca(): array { - if ($this->fieldConfiguration instanceof FieldConfigurationInterface) { - return $this->fieldConfiguration->getTca(); + if ($this->fieldType instanceof FieldTypeInterface) { + return $this->fieldType->getTca(); } return []; } - public function getFieldConfiguration(): FieldConfigurationInterface + public function getFieldType(): FieldTypeInterface { - return $this->fieldConfiguration; + return $this->fieldType; } public function withUniqueIdentifier(string $uniqueIdentifier): TcaFieldDefinition @@ -138,10 +134,10 @@ public function withUseExistingField(bool $useExistingField): TcaFieldDefinition return $clone; } - public function withFieldConfiguration(FieldConfigurationInterface $fieldConfiguration): TcaFieldDefinition + public function withFieldType(FieldTypeInterface $fieldType): TcaFieldDefinition { $clone = clone $this; - $clone->fieldConfiguration = $fieldConfiguration; + $clone->fieldType = $fieldType; return $clone; } diff --git a/Classes/FieldConfiguration/FieldType.php b/Classes/FieldConfiguration/FieldType.php deleted file mode 100644 index 2438310f..00000000 --- a/Classes/FieldConfiguration/FieldType.php +++ /dev/null @@ -1,149 +0,0 @@ - 'category', - self::CHECKBOX => 'check', - self::COLLECTION => 'inline', - self::COLOR => 'color', - self::DATETIME => 'datetime', - self::SLUG => 'slug', - self::EMAIL => 'email', - self::FILE => 'file', - self::JSON => 'json', - self::LANGUAGE => 'language', - self::LINK => 'link', - self::NUMBER => 'number', - self::RADIO => 'radio', - self::SELECT => 'select', - self::RELATION => 'group', - self::FOLDER => 'folder', - self::TEXT => 'input', - self::TEXTAREA => 'text', - self::FLEXFORM => 'flex', - self::PASSWORD => 'password', - self::PALETTE, self::LINEBREAK, self::TAB => '', - self::UUID => 'uuid', - }; - } - - public function isSearchable(): bool - { - return in_array( - $this, - [ - self::TEXT, - self::TEXTAREA, - self::EMAIL, - self::COLOR, - self::LINK, - self::SLUG, - self::FLEXFORM, - self::JSON, - self::UUID, - ], - true - ); - } - - public function isRenderable(): bool - { - return !in_array($this, [self::PALETTE, self::LINEBREAK, self::TAB], true); - } - - public function isRelation(): bool - { - return in_array($this, [self::SELECT, self::COLLECTION, self::RELATION]); - } - - public function hasItems(): bool - { - return in_array($this, [self::SELECT, self::RADIO, self::CHECKBOX]); - } - - public static function isValidFlexFormField(FieldType $type): bool - { - if (!$type->isRenderable()) { - return false; - } - return $type !== self::FLEXFORM; - } - - public function getFieldConfiguration(array $config): FieldConfigurationInterface - { - return match ($this) { - self::CATEGORY => CategoryFieldConfiguration::createFromArray($config), - self::CHECKBOX => CheckboxFieldConfiguration::createFromArray($config), - self::COLLECTION => CollectionFieldConfiguration::createFromArray($config), - self::COLOR => ColorFieldConfiguration::createFromArray($config), - self::DATETIME => DateTimeFieldConfiguration::createFromArray($config), - self::SLUG => SlugFieldConfiguration::createFromArray($config), - self::EMAIL => EmailFieldConfiguration::createFromArray($config), - self::FILE => FileFieldConfiguration::createFromArray($config), - self::JSON => JsonFieldConfiguration::createFromArray($config), - self::LANGUAGE => LanguageFieldConfiguration::createFromArray($config), - self::LINK => LinkFieldConfiguration::createFromArray($config), - self::NUMBER => NumberFieldConfiguration::createFromArray($config), - self::RADIO => RadioFieldConfiguration::createFromArray($config), - self::SELECT => SelectFieldConfiguration::createFromArray($config), - self::RELATION => RelationFieldConfiguration::createFromArray($config), - self::FOLDER => FolderFieldConfiguration::createFromArray($config), - self::TEXT => TextFieldConfiguration::createFromArray($config), - self::TEXTAREA => TextareaFieldConfiguration::createFromArray($config), - self::FLEXFORM => FlexFormFieldConfiguration::createFromArray($config), - self::PASSWORD => PasswordFieldConfiguration::createFromArray($config), - self::PALETTE => PaletteFieldConfiguration::createFromArray($config), - self::LINEBREAK => LinebreakFieldConfiguration::createFromArray($config), - self::TAB => TabFieldConfiguration::createFromArray($config), - self::UUID => UuidFieldConfiguration::createFromArray($config), - }; - } -} diff --git a/Classes/FieldConfiguration/CategoryFieldConfiguration.php b/Classes/FieldType/CategoryFieldType.php similarity index 81% rename from Classes/FieldConfiguration/CategoryFieldConfiguration.php rename to Classes/FieldType/CategoryFieldType.php index 42037b0c..2b94bb51 100644 --- a/Classes/FieldConfiguration/CategoryFieldConfiguration.php +++ b/Classes/FieldType/CategoryFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class CategoryFieldConfiguration implements FieldConfigurationInterface +final class CategoryFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::CATEGORY; private string|int $default = ''; private bool $readOnly = false; private int $size = 0; @@ -34,7 +33,7 @@ final class CategoryFieldConfiguration implements FieldConfigurationInterface private array $treeConfig = []; private string $relationship = ''; - public static function createFromArray(array $settings): CategoryFieldConfiguration + public static function createFromArray(array $settings): CategoryFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -56,7 +55,7 @@ public static function createFromArray(array $settings): CategoryFieldConfigurat public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcaType(); if ($this->default !== '') { $config['default'] = $this->default; } @@ -90,8 +89,33 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Category'; + } + + public static function getTcaType(): string + { + return 'category'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/CheckboxFieldConfiguration.php b/Classes/FieldType/CheckboxFieldType.php similarity index 81% rename from Classes/FieldConfiguration/CheckboxFieldConfiguration.php rename to Classes/FieldType/CheckboxFieldType.php index 0870fbc0..32dbbda0 100644 --- a/Classes/FieldConfiguration/CheckboxFieldConfiguration.php +++ b/Classes/FieldType/CheckboxFieldType.php @@ -15,17 +15,16 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class CheckboxFieldConfiguration implements FieldConfigurationInterface +final class CheckboxFieldType implements FieldTypeInterface { use WithCommonProperties; use WithCustomProperties; - private FieldType $fieldType = FieldType::CHECKBOX; private int $default = 0; private bool $readOnly = false; private bool $invertStateDisplay = false; @@ -35,7 +34,7 @@ final class CheckboxFieldConfiguration implements FieldConfigurationInterface private array $validation = []; private array $items = []; - public static function createFromArray(array $settings): CheckboxFieldConfiguration + public static function createFromArray(array $settings): CheckboxFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -55,7 +54,7 @@ public static function createFromArray(array $settings): CheckboxFieldConfigurat public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcaType(); if ($this->default > 0) { $config['default'] = $this->default; } @@ -90,8 +89,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` int(11) UNSIGNED DEFAULT '0' NOT NULL"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Checkbox'; + } + + public static function getTcaType(): string + { + return 'check'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return true; } } diff --git a/Classes/FieldConfiguration/CollectionFieldConfiguration.php b/Classes/FieldType/CollectionFieldType.php similarity index 91% rename from Classes/FieldConfiguration/CollectionFieldConfiguration.php rename to Classes/FieldType/CollectionFieldType.php index 9f379a43..a3bdb435 100644 --- a/Classes/FieldConfiguration/CollectionFieldConfiguration.php +++ b/Classes/FieldType/CollectionFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class CollectionFieldConfiguration implements FieldConfigurationInterface +final class CollectionFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::COLLECTION; private bool $readOnly = false; private int $size = 0; private bool $localizeReferencesAtParentLocalization = false; @@ -51,7 +50,7 @@ final class CollectionFieldConfiguration implements FieldConfigurationInterface private string $symmetric_label = ''; private string $symmetric_sortby = ''; - public static function createFromArray(array $settings): CollectionFieldConfiguration + public static function createFromArray(array $settings): CollectionFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -86,7 +85,7 @@ public static function createFromArray(array $settings): CollectionFieldConfigur public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->readOnly) { $config['readOnly'] = true; } @@ -171,8 +170,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` int(11) UNSIGNED DEFAULT '0' NOT NULL"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Collection'; + } + + public static function getTcaType(): string + { + return 'inline'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return true; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/ColorFieldConfiguration.php b/Classes/FieldType/ColorFieldType.php similarity index 82% rename from Classes/FieldConfiguration/ColorFieldConfiguration.php rename to Classes/FieldType/ColorFieldType.php index 3337f56f..25ed2c32 100644 --- a/Classes/FieldConfiguration/ColorFieldConfiguration.php +++ b/Classes/FieldType/ColorFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class ColorFieldConfiguration implements FieldConfigurationInterface +final class ColorFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::COLOR; private string $default = ''; private bool $readOnly = false; private int $size = 0; @@ -35,7 +34,7 @@ final class ColorFieldConfiguration implements FieldConfigurationInterface private array $valuePicker = []; private ?bool $autocomplete = null; - public static function createFromArray(array $settings): ColorFieldConfiguration + public static function createFromArray(array $settings): ColorFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -57,7 +56,7 @@ public static function createFromArray(array $settings): ColorFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->size !== 0) { $config['size'] = $this->size; } @@ -98,8 +97,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` VARCHAR(255) DEFAULT ''" . $null; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Color'; + } + + public static function getTcaType(): string + { + return 'color'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/DateTimeFieldConfiguration.php b/Classes/FieldType/DateTimeFieldType.php similarity index 86% rename from Classes/FieldConfiguration/DateTimeFieldConfiguration.php rename to Classes/FieldType/DateTimeFieldType.php index f0dc995a..c37e959c 100644 --- a/Classes/FieldConfiguration/DateTimeFieldConfiguration.php +++ b/Classes/FieldType/DateTimeFieldType.php @@ -15,18 +15,17 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; use TYPO3\CMS\Core\Utility\MathUtility; /** * @internal Not part of TYPO3's public API. */ -final class DateTimeFieldConfiguration implements FieldConfigurationInterface +final class DateTimeFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::DATETIME; private string|int $default = ''; private bool $readOnly = false; private int $size = 0; @@ -39,7 +38,7 @@ final class DateTimeFieldConfiguration implements FieldConfigurationInterface private bool $disableAgeDisplay = false; private string $format = ''; - public static function createFromArray(array $settings): DateTimeFieldConfiguration + public static function createFromArray(array $settings): DateTimeFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -64,7 +63,7 @@ public static function createFromArray(array $settings): DateTimeFieldConfigurat public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== '') { $config['default'] = $this->dbType !== '' ? $this->default : $this->convertDateToTimestamp($this->default); } @@ -115,14 +114,39 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'DateTime'; + } + + public static function getTcaType(): string + { + return 'datetime'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } /** * Returns a timestamp as integer. Returns 0 if it could not create a timestamp. - */ + */ private function convertDateToTimestamp(string|int $date): int { $isTime = $this->format === 'time'; diff --git a/Classes/FieldConfiguration/EmailFieldConfiguration.php b/Classes/FieldType/EmailFieldType.php similarity index 83% rename from Classes/FieldConfiguration/EmailFieldConfiguration.php rename to Classes/FieldType/EmailFieldType.php index 27f16cf8..6b1fcef6 100644 --- a/Classes/FieldConfiguration/EmailFieldConfiguration.php +++ b/Classes/FieldType/EmailFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class EmailFieldConfiguration implements FieldConfigurationInterface +final class EmailFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::EMAIL; private string $default = ''; private bool $readOnly = false; private int $size = 0; @@ -36,7 +35,7 @@ final class EmailFieldConfiguration implements FieldConfigurationInterface private ?bool $autocomplete = null; private array $valuePicker = []; - public static function createFromArray(array $settings): EmailFieldConfiguration + public static function createFromArray(array $settings): EmailFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -58,7 +57,7 @@ public static function createFromArray(array $settings): EmailFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->size !== 0) { $config['size'] = $this->size; } @@ -103,8 +102,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` VARCHAR(255) DEFAULT ''" . $null; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Email'; + } + + public static function getTcaType(): string + { + return 'email'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldType/FieldType.php b/Classes/FieldType/FieldType.php new file mode 100644 index 00000000..2ef6c61c --- /dev/null +++ b/Classes/FieldType/FieldType.php @@ -0,0 +1,60 @@ +isRenderable()) { + return false; + } + $fieldTypeEnum = self::tryFrom($fieldType::getName()); + return $fieldTypeEnum !== self::FLEXFORM; + } +} diff --git a/Classes/FieldConfiguration/FieldConfigurationInterface.php b/Classes/FieldType/FieldTypeInterface.php similarity index 57% rename from Classes/FieldConfiguration/FieldConfigurationInterface.php rename to Classes/FieldType/FieldTypeInterface.php index 8c85f3fc..04fae892 100644 --- a/Classes/FieldConfiguration/FieldConfigurationInterface.php +++ b/Classes/FieldType/FieldTypeInterface.php @@ -15,15 +15,23 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; + +use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; /** * @internal Not part of TYPO3's public API. */ -interface FieldConfigurationInterface +#[AutoconfigureTag('content_blocks.field_type')] +interface FieldTypeInterface { - public static function createFromArray(array $settings): FieldConfigurationInterface; + public static function createFromArray(array $settings): FieldTypeInterface; public function getTca(): array; public function getSql(string $uniqueColumnName): string; - public function getFieldType(): FieldType; + public static function getName(): string; + public static function getTcaType(): string; + public static function isSearchable(): bool; + public static function isRenderable(): bool; + public static function isRelation(): bool; + public static function hasItems(): bool; } diff --git a/Classes/FieldType/FieldTypeRegistry.php b/Classes/FieldType/FieldTypeRegistry.php new file mode 100644 index 00000000..89d0f12f --- /dev/null +++ b/Classes/FieldType/FieldTypeRegistry.php @@ -0,0 +1,67 @@ + + */ + #[TaggedIterator('content_blocks.field_type', defaultIndexMethod: 'getName')] + protected \IteratorAggregate $fieldTypes, + ) { + $this->fieldTypesArray = iterator_to_array($this->fieldTypes); + } + + public function has(string $fieldTypeName): bool + { + return array_key_exists($fieldTypeName, $this->fieldTypesArray); + } + + public function get(string $fieldTypeName): FieldTypeInterface + { + if (!array_key_exists($fieldTypeName, $this->fieldTypesArray)) { + throw new \InvalidArgumentException( + 'Field type with name "' . $fieldTypeName . '" does not exist', + 1710083790 + ); + } + return $this->fieldTypesArray[$fieldTypeName]; + } + + /** + * @return FieldTypeInterface[] + */ + public function getAll(): array + { + return $this->fieldTypesArray; + } + + public function getIterator(): \Traversable + { + return $this->fieldTypes; + } +} diff --git a/Classes/FieldConfiguration/FileFieldConfiguration.php b/Classes/FieldType/FileFieldType.php similarity index 89% rename from Classes/FieldConfiguration/FileFieldConfiguration.php rename to Classes/FieldType/FileFieldType.php index 9f9a3d4d..c326c850 100644 --- a/Classes/FieldConfiguration/FileFieldConfiguration.php +++ b/Classes/FieldType/FileFieldType.php @@ -15,7 +15,7 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; use TYPO3\CMS\Core\Preparations\TcaPreparation; use TYPO3\CMS\Core\Resource\AbstractFile; @@ -24,11 +24,10 @@ /** * @internal Not part of TYPO3's public API. */ -final class FileFieldConfiguration implements FieldConfigurationInterface +final class FileFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::FILE; private array|string $allowed = []; private array|string $disallowed = []; private array $appearance = []; @@ -39,7 +38,7 @@ final class FileFieldConfiguration implements FieldConfigurationInterface private bool $extendedPalette = true; private array $cropVariants = []; - public static function createFromArray(array $settings): FileFieldConfiguration + public static function createFromArray(array $settings): FileFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -64,7 +63,7 @@ public static function createFromArray(array $settings): FileFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->allowed !== [] && $this->allowed !== '') { $config['allowed'] = TcaPreparation::prepareFileExtensions($this->allowed); } @@ -137,8 +136,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` int(11) UNSIGNED DEFAULT '0' NOT NULL"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'File'; + } + + public static function getTcaType(): string + { + return 'file'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/FlexFormFieldConfiguration.php b/Classes/FieldType/FlexFormFieldType.php similarity index 74% rename from Classes/FieldConfiguration/FlexFormFieldConfiguration.php rename to Classes/FieldType/FlexFormFieldType.php index ab8c0ca5..a82be6eb 100644 --- a/Classes/FieldConfiguration/FlexFormFieldConfiguration.php +++ b/Classes/FieldType/FlexFormFieldType.php @@ -15,24 +15,23 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; use TYPO3\CMS\ContentBlocks\Definition\FlexForm\FlexFormDefinition; /** * @internal Not part of TYPO3's public API. */ -final class FlexFormFieldConfiguration implements FieldConfigurationInterface +final class FlexFormFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::FLEXFORM; /** @var FlexFormDefinition[] */ private array $flexFormDefinitions = []; private string $ds_pointerField = ''; private array $ds = []; - public static function createFromArray(array $settings): FlexFormFieldConfiguration + public static function createFromArray(array $settings): FlexFormFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -45,7 +44,7 @@ public static function createFromArray(array $settings): FlexFormFieldConfigurat public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->ds_pointerField !== '') { $config['ds_pointerField'] = $this->ds_pointerField; } @@ -59,9 +58,34 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` text"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'FlexForm'; + } + + public static function getTcaType(): string + { + return 'flex'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return true; + } + + public static function hasItems(): bool + { + return false; } /** diff --git a/Classes/FieldConfiguration/FolderFieldConfiguration.php b/Classes/FieldType/FolderFieldType.php similarity index 83% rename from Classes/FieldConfiguration/FolderFieldConfiguration.php rename to Classes/FieldType/FolderFieldType.php index e63ea281..443d519b 100644 --- a/Classes/FieldConfiguration/FolderFieldConfiguration.php +++ b/Classes/FieldType/FolderFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class FolderFieldConfiguration implements FieldConfigurationInterface +final class FolderFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::FOLDER; private bool $recursive = false; private string $default = ''; private bool $readOnly = false; @@ -36,7 +35,7 @@ final class FolderFieldConfiguration implements FieldConfigurationInterface private bool $hideMoveIcons = false; private array $elementBrowserEntryPoints = []; - public static function createFromArray(array $settings): FolderFieldConfiguration + public static function createFromArray(array $settings): FolderFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -57,7 +56,7 @@ public static function createFromArray(array $settings): FolderFieldConfiguratio public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== '') { $config['default'] = $this->default; } @@ -94,9 +93,34 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` text"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Folder'; + } + + public static function getTcaType(): string + { + return 'folder'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } public function isRecursive(): bool diff --git a/Classes/FieldConfiguration/JsonFieldConfiguration.php b/Classes/FieldType/JsonFieldType.php similarity index 79% rename from Classes/FieldConfiguration/JsonFieldConfiguration.php rename to Classes/FieldType/JsonFieldType.php index db3ef1cc..1e3b58ae 100644 --- a/Classes/FieldConfiguration/JsonFieldConfiguration.php +++ b/Classes/FieldType/JsonFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class JsonFieldConfiguration implements FieldConfigurationInterface +final class JsonFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::JSON; private string $default = ''; private int $cols = 0; private int $rows = 0; @@ -33,7 +32,7 @@ final class JsonFieldConfiguration implements FieldConfigurationInterface private bool $readOnly = false; private string $placeholder = ''; - public static function createFromArray(array $settings): JsonFieldConfiguration + public static function createFromArray(array $settings): JsonFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -51,7 +50,7 @@ public static function createFromArray(array $settings): JsonFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== '') { $config['default'] = $this->default; } @@ -83,8 +82,33 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Json'; + } + + public static function getTcaType(): string + { + return 'json'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/LanguageFieldConfiguration.php b/Classes/FieldType/LanguageFieldType.php similarity index 69% rename from Classes/FieldConfiguration/LanguageFieldConfiguration.php rename to Classes/FieldType/LanguageFieldType.php index afa40237..d38db66f 100644 --- a/Classes/FieldConfiguration/LanguageFieldConfiguration.php +++ b/Classes/FieldType/LanguageFieldType.php @@ -15,21 +15,20 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class LanguageFieldConfiguration implements FieldConfigurationInterface +final class LanguageFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::LANGUAGE; private int $default = 0; private bool $readOnly = false; private bool $required = false; - public static function createFromArray(array $settings): FieldConfigurationInterface + public static function createFromArray(array $settings): LanguageFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -42,7 +41,7 @@ public static function createFromArray(array $settings): FieldConfigurationInter public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== 0) { $config['default'] = $this->default; } @@ -62,8 +61,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` int(11) DEFAULT '0' NOT NULL"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Language'; + } + + public static function getTcaType(): string + { + return 'language'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/TabFieldConfiguration.php b/Classes/FieldType/LinebreakFieldType.php similarity index 52% rename from Classes/FieldConfiguration/TabFieldConfiguration.php rename to Classes/FieldType/LinebreakFieldType.php index 61379506..b3ba4562 100644 --- a/Classes/FieldConfiguration/TabFieldConfiguration.php +++ b/Classes/FieldType/LinebreakFieldType.php @@ -15,16 +15,14 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class TabFieldConfiguration implements FieldConfigurationInterface +final class LinebreakFieldType implements FieldTypeInterface { - private FieldType $fieldType = FieldType::TAB; - - public static function createFromArray(array $settings): FieldConfigurationInterface + public static function createFromArray(array $settings): LinebreakFieldType { return new self(); } @@ -39,8 +37,33 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string + { + return 'Linebreak'; + } + + public static function getTcaType(): string + { + return ''; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return false; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool { - return $this->fieldType; + return false; } } diff --git a/Classes/FieldConfiguration/LinkFieldConfiguration.php b/Classes/FieldType/LinkFieldType.php similarity index 84% rename from Classes/FieldConfiguration/LinkFieldConfiguration.php rename to Classes/FieldType/LinkFieldType.php index 1b9f6543..c600f5d9 100644 --- a/Classes/FieldConfiguration/LinkFieldConfiguration.php +++ b/Classes/FieldType/LinkFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class LinkFieldConfiguration implements FieldConfigurationInterface +final class LinkFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::LINK; private string $default = ''; private bool $readOnly = false; private int $size = 0; @@ -37,7 +36,7 @@ final class LinkFieldConfiguration implements FieldConfigurationInterface private array $allowedTypes = []; private array $appearance = []; - public static function createFromArray(array $settings): LinkFieldConfiguration + public static function createFromArray(array $settings): LinkFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -61,7 +60,7 @@ public static function createFromArray(array $settings): LinkFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->size !== 0) { $config['size'] = $this->size; } @@ -108,8 +107,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` VARCHAR(1024) DEFAULT ''" . $null; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Link'; + } + + public static function getTcaType(): string + { + return 'link'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/NumberFieldConfiguration.php b/Classes/FieldType/NumberFieldType.php similarity index 85% rename from Classes/FieldConfiguration/NumberFieldConfiguration.php rename to Classes/FieldType/NumberFieldType.php index 65bfb0a3..b8caf8ef 100644 --- a/Classes/FieldConfiguration/NumberFieldConfiguration.php +++ b/Classes/FieldType/NumberFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class NumberFieldConfiguration implements FieldConfigurationInterface +final class NumberFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::NUMBER; private int|float $default = 0; private bool $readOnly = false; private int $size = 0; @@ -38,7 +37,7 @@ final class NumberFieldConfiguration implements FieldConfigurationInterface private array $slider = []; private string $format = ''; - public static function createFromArray(array $settings): NumberFieldConfiguration + public static function createFromArray(array $settings): NumberFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -64,7 +63,7 @@ public static function createFromArray(array $settings): NumberFieldConfiguratio public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->size !== 0) { $config['size'] = $this->size; } @@ -118,8 +117,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` int(11) DEFAULT '0'" . $null; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Number'; + } + + public static function getTcaType(): string + { + return 'number'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/LinebreakFieldConfiguration.php b/Classes/FieldType/PaletteFieldType.php similarity index 52% rename from Classes/FieldConfiguration/LinebreakFieldConfiguration.php rename to Classes/FieldType/PaletteFieldType.php index 34f4aa4f..5897f07a 100644 --- a/Classes/FieldConfiguration/LinebreakFieldConfiguration.php +++ b/Classes/FieldType/PaletteFieldType.php @@ -15,16 +15,14 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class LinebreakFieldConfiguration implements FieldConfigurationInterface +final class PaletteFieldType implements FieldTypeInterface { - private FieldType $fieldType = FieldType::LINEBREAK; - - public static function createFromArray(array $settings): FieldConfigurationInterface + public static function createFromArray(array $settings): PaletteFieldType { return new self(); } @@ -39,8 +37,33 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string + { + return 'Palette'; + } + + public static function getTcaType(): string + { + return ''; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return false; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool { - return $this->fieldType; + return false; } } diff --git a/Classes/FieldConfiguration/PasswordFieldConfiguration.php b/Classes/FieldType/PasswordFieldType.php similarity index 83% rename from Classes/FieldConfiguration/PasswordFieldConfiguration.php rename to Classes/FieldType/PasswordFieldType.php index b22e3bf1..a8051136 100644 --- a/Classes/FieldConfiguration/PasswordFieldConfiguration.php +++ b/Classes/FieldType/PasswordFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class PasswordFieldConfiguration implements FieldConfigurationInterface +final class PasswordFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::PASSWORD; private string $default = ''; private bool $readOnly = false; private bool $required = false; @@ -36,7 +35,7 @@ final class PasswordFieldConfiguration implements FieldConfigurationInterface private bool $hashed = true; private string $passwordPolicy = ''; - public static function createFromArray(array $settings): PasswordFieldConfiguration + public static function createFromArray(array $settings): PasswordFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -59,7 +58,7 @@ public static function createFromArray(array $settings): PasswordFieldConfigurat public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->size !== 0) { $config['size'] = $this->size; } @@ -103,8 +102,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` VARCHAR(255) DEFAULT ''" . $null; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Password'; + } + + public static function getTcaType(): string + { + return 'password'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/RadioFieldConfiguration.php b/Classes/FieldType/RadioFieldType.php similarity index 76% rename from Classes/FieldConfiguration/RadioFieldConfiguration.php rename to Classes/FieldType/RadioFieldType.php index c7b29e35..06b93f5d 100644 --- a/Classes/FieldConfiguration/RadioFieldConfiguration.php +++ b/Classes/FieldType/RadioFieldType.php @@ -15,23 +15,22 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class RadioFieldConfiguration implements FieldConfigurationInterface +final class RadioFieldType implements FieldTypeInterface { use WithCommonProperties; use WithCustomProperties; - private FieldType $fieldType = FieldType::RADIO; private string|int $default = ''; private bool $readOnly = false; private string $itemsProcFunc = ''; private array $items = []; - public static function createFromArray(array $settings): RadioFieldConfiguration + public static function createFromArray(array $settings): RadioFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -50,7 +49,7 @@ public static function createFromArray(array $settings): RadioFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== '') { $config['default'] = $this->default; } @@ -73,8 +72,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` VARCHAR(255) DEFAULT '' NOT NULL"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Radio'; + } + + public static function getTcaType(): string + { + return 'radio'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return true; } } diff --git a/Classes/FieldConfiguration/RelationFieldConfiguration.php b/Classes/FieldType/RelationFieldType.php similarity index 90% rename from Classes/FieldConfiguration/RelationFieldConfiguration.php rename to Classes/FieldType/RelationFieldType.php index 27eae356..8e521d4e 100644 --- a/Classes/FieldConfiguration/RelationFieldConfiguration.php +++ b/Classes/FieldType/RelationFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class RelationFieldConfiguration implements FieldConfigurationInterface +final class RelationFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::RELATION; private string|int $default = ''; private string $allowed = ''; private string $foreign_table = ''; @@ -49,7 +48,7 @@ final class RelationFieldConfiguration implements FieldConfigurationInterface private array $suggestOptions = []; private array $appearance = []; - public static function createFromArray(array $settings): RelationFieldConfiguration + public static function createFromArray(array $settings): RelationFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -86,7 +85,7 @@ public static function createFromArray(array $settings): RelationFieldConfigurat public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== '') { $config['default'] = $this->default; } @@ -165,8 +164,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` text"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Relation'; + } + + public static function getTcaType(): string + { + return 'group'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return true; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/SelectFieldConfiguration.php b/Classes/FieldType/SelectFieldType.php similarity index 92% rename from Classes/FieldConfiguration/SelectFieldConfiguration.php rename to Classes/FieldType/SelectFieldType.php index 992bdde0..16ed6853 100644 --- a/Classes/FieldConfiguration/SelectFieldConfiguration.php +++ b/Classes/FieldType/SelectFieldType.php @@ -15,17 +15,16 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class SelectFieldConfiguration implements FieldConfigurationInterface +final class SelectFieldType implements FieldTypeInterface { use WithCommonProperties; use WithCustomProperties; - private FieldType $fieldType = FieldType::SELECT; private string|int $default = ''; private bool $readOnly = false; private int $size = 0; @@ -57,7 +56,7 @@ final class SelectFieldConfiguration implements FieldConfigurationInterface // Only for renderType="selectTree" private array $treeConfig = []; - public static function createFromArray(array $settings): SelectFieldConfiguration + public static function createFromArray(array $settings): SelectFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -98,7 +97,7 @@ public static function createFromArray(array $settings): SelectFieldConfiguratio public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== '') { $config['default'] = $this->default; } @@ -185,8 +184,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` VARCHAR(255) DEFAULT '' NOT NULL"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Select'; + } + + public static function getTcaType(): string + { + return 'select'; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return true; + } + + public static function hasItems(): bool + { + return true; } } diff --git a/Classes/FieldConfiguration/SlugFieldConfiguration.php b/Classes/FieldType/SlugFieldType.php similarity index 79% rename from Classes/FieldConfiguration/SlugFieldConfiguration.php rename to Classes/FieldType/SlugFieldType.php index 664e6d43..595bdbcf 100644 --- a/Classes/FieldConfiguration/SlugFieldConfiguration.php +++ b/Classes/FieldType/SlugFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class SlugFieldConfiguration implements FieldConfigurationInterface +final class SlugFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::SLUG; private bool $readOnly = false; private int $size = 0; private array $appearance = []; @@ -33,7 +32,7 @@ final class SlugFieldConfiguration implements FieldConfigurationInterface private array $generatorOptions = []; private bool $prependSlash = false; - public static function createFromArray(array $settings): FieldConfigurationInterface + public static function createFromArray(array $settings): FieldTypeInterface { $self = new self(); $self->setCommonProperties($settings); @@ -50,7 +49,7 @@ public static function createFromArray(array $settings): FieldConfigurationInter public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->readOnly) { $config['readOnly'] = true; } @@ -81,8 +80,33 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Slug'; + } + + public static function getTcaType(): string + { + return 'slug'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/PaletteFieldConfiguration.php b/Classes/FieldType/TabFieldType.php similarity index 52% rename from Classes/FieldConfiguration/PaletteFieldConfiguration.php rename to Classes/FieldType/TabFieldType.php index 2c60eb68..ae7628e6 100644 --- a/Classes/FieldConfiguration/PaletteFieldConfiguration.php +++ b/Classes/FieldType/TabFieldType.php @@ -15,16 +15,14 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class PaletteFieldConfiguration implements FieldConfigurationInterface +final class TabFieldType implements FieldTypeInterface { - private FieldType $fieldType = FieldType::PALETTE; - - public static function createFromArray(array $settings): FieldConfigurationInterface + public static function createFromArray(array $settings): TabFieldType { return new self(); } @@ -39,8 +37,33 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string + { + return 'Tab'; + } + + public static function getTcaType(): string + { + return ''; + } + + public static function isSearchable(): bool + { + return false; + } + + public static function isRenderable(): bool + { + return false; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool { - return $this->fieldType; + return false; } } diff --git a/Classes/FieldConfiguration/TextFieldConfiguration.php b/Classes/FieldType/TextFieldType.php similarity index 85% rename from Classes/FieldConfiguration/TextFieldConfiguration.php rename to Classes/FieldType/TextFieldType.php index 9925c753..73f054eb 100644 --- a/Classes/FieldConfiguration/TextFieldConfiguration.php +++ b/Classes/FieldType/TextFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class TextFieldConfiguration implements FieldConfigurationInterface +final class TextFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::TEXT; private string $default = ''; private bool $readOnly = false; private int $size = 0; @@ -39,7 +38,7 @@ final class TextFieldConfiguration implements FieldConfigurationInterface private array $eval = []; private ?bool $autocomplete = null; - public static function createFromArray(array $settings): TextFieldConfiguration + public static function createFromArray(array $settings): TextFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -65,7 +64,7 @@ public static function createFromArray(array $settings): TextFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->size !== 0) { $config['size'] = $this->size; } @@ -118,8 +117,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` VARCHAR(255) DEFAULT ''" . $null; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Text'; + } + + public static function getTcaType(): string + { + return 'input'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/TextareaFieldConfiguration.php b/Classes/FieldType/TextareaFieldType.php similarity index 87% rename from Classes/FieldConfiguration/TextareaFieldConfiguration.php rename to Classes/FieldType/TextareaFieldType.php index ce72f21c..6ba18b94 100644 --- a/Classes/FieldConfiguration/TextareaFieldConfiguration.php +++ b/Classes/FieldType/TextareaFieldType.php @@ -15,16 +15,15 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class TextareaFieldConfiguration implements FieldConfigurationInterface +final class TextareaFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::TEXTAREA; private string $default = ''; private bool $readOnly = false; private bool $required = false; @@ -44,7 +43,7 @@ final class TextareaFieldConfiguration implements FieldConfigurationInterface private string $richtextConfiguration = ''; private string $format = ''; - public static function createFromArray(array $settings): TextareaFieldConfiguration + public static function createFromArray(array $settings): TextareaFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -73,7 +72,7 @@ public static function createFromArray(array $settings): TextareaFieldConfigurat public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->default !== '') { $config['default'] = $this->default; } @@ -137,8 +136,33 @@ public function getSql(string $uniqueColumnName): string return "`$uniqueColumnName` text"; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Textarea'; + } + + public static function getTcaType(): string + { + return 'text'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/UuidFieldConfiguration.php b/Classes/FieldType/UuidFieldType.php similarity index 72% rename from Classes/FieldConfiguration/UuidFieldConfiguration.php rename to Classes/FieldType/UuidFieldType.php index a2923645..8374bd99 100644 --- a/Classes/FieldConfiguration/UuidFieldConfiguration.php +++ b/Classes/FieldType/UuidFieldType.php @@ -15,21 +15,20 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. */ -final class UuidFieldConfiguration implements FieldConfigurationInterface +final class UuidFieldType implements FieldTypeInterface { use WithCommonProperties; - private FieldType $fieldType = FieldType::UUID; private int $size = 0; private bool $enableCopyToClipboard = true; private ?int $version = null; - public static function createFromArray(array $settings): UuidFieldConfiguration + public static function createFromArray(array $settings): UuidFieldType { $self = new self(); $self->setCommonProperties($settings); @@ -45,7 +44,7 @@ public static function createFromArray(array $settings): UuidFieldConfiguration public function getTca(): array { $tca = $this->toTca(); - $config['type'] = $this->fieldType->getTcaType(); + $config['type'] = self::getTcatype(); if ($this->size !== 0) { $config['size'] = $this->size; } @@ -65,8 +64,33 @@ public function getSql(string $uniqueColumnName): string return ''; } - public function getFieldType(): FieldType + public static function getName(): string { - return $this->fieldType; + return 'Uuid'; + } + + public static function getTcaType(): string + { + return 'uuid'; + } + + public static function isSearchable(): bool + { + return true; + } + + public static function isRenderable(): bool + { + return true; + } + + public static function isRelation(): bool + { + return false; + } + + public static function hasItems(): bool + { + return false; } } diff --git a/Classes/FieldConfiguration/WithCommonProperties.php b/Classes/FieldType/WithCommonProperties.php similarity index 98% rename from Classes/FieldConfiguration/WithCommonProperties.php rename to Classes/FieldType/WithCommonProperties.php index 31565703..f8fa140b 100644 --- a/Classes/FieldConfiguration/WithCommonProperties.php +++ b/Classes/FieldType/WithCommonProperties.php @@ -15,7 +15,7 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. diff --git a/Classes/FieldConfiguration/WithCustomProperties.php b/Classes/FieldType/WithCustomProperties.php similarity index 95% rename from Classes/FieldConfiguration/WithCustomProperties.php rename to Classes/FieldType/WithCustomProperties.php index 68c2b7a3..6937ec28 100644 --- a/Classes/FieldConfiguration/WithCustomProperties.php +++ b/Classes/FieldType/WithCustomProperties.php @@ -15,7 +15,7 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\ContentBlocks\FieldConfiguration; +namespace TYPO3\CMS\ContentBlocks\FieldType; /** * @internal Not part of TYPO3's public API. diff --git a/Classes/Generator/SqlGenerator.php b/Classes/Generator/SqlGenerator.php index 14dcf71c..7e8ac30f 100644 --- a/Classes/Generator/SqlGenerator.php +++ b/Classes/Generator/SqlGenerator.php @@ -19,6 +19,7 @@ use TYPO3\CMS\ContentBlocks\Definition\Factory\TableDefinitionCollectionFactory; use TYPO3\CMS\ContentBlocks\Definition\TableDefinition; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeRegistry; use TYPO3\CMS\ContentBlocks\Loader\ContentBlockLoader; use TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory; use TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent; @@ -32,6 +33,7 @@ public function __construct( protected readonly ContentBlockLoader $contentBlockLoader, protected readonly TableDefinitionCollectionFactory $tableDefinitionCollectionFactory, protected readonly SimpleTcaSchemaFactory $simpleTcaSchemaFactory, + protected readonly FieldTypeRegistry $fieldTypeRegistry, ) {} public function __invoke(AlterTableDefinitionStatementsEvent $event): void @@ -46,6 +48,7 @@ public function generate(): array $contentBlockRegistry = $this->contentBlockLoader->loadUncached(); $tableDefinitionCollection = $this->tableDefinitionCollectionFactory->createUncached( $contentBlockRegistry, + $this->fieldTypeRegistry, $this->simpleTcaSchemaFactory ); $sql = []; diff --git a/Classes/Generator/TcaGenerator.php b/Classes/Generator/TcaGenerator.php index 24146348..8803e515 100644 --- a/Classes/Generator/TcaGenerator.php +++ b/Classes/Generator/TcaGenerator.php @@ -31,8 +31,8 @@ use TYPO3\CMS\ContentBlocks\Definition\TCA\LinebreakDefinition; use TYPO3\CMS\ContentBlocks\Definition\TCA\TabDefinition; use TYPO3\CMS\ContentBlocks\Definition\TcaFieldDefinition; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FlexFormFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FlexFormFieldType; use TYPO3\CMS\ContentBlocks\Registry\LanguageFileRegistry; use TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory; use TYPO3\CMS\ContentBlocks\Service\SystemExtensionAvailability; @@ -202,13 +202,13 @@ protected function generateTableTca(TableDefinition $tableDefinition, array $bas $currentPalettesTca = $tca['palettes'] ?? []; $tca['palettes'] = $currentPalettesTca + $this->generatePalettesTca($tableDefinition); foreach ($tableDefinition->getTcaFieldDefinitionCollection() as $column) { - $fieldConfiguration = $column->getFieldConfiguration(); - if ($fieldConfiguration instanceof FlexFormFieldConfiguration) { + $fieldType = $column->getFieldType(); + if ($fieldType instanceof FlexFormFieldType) { $dataStructure = []; - foreach ($fieldConfiguration->getFlexFormDefinitions() as $flexFormDefinition) { + foreach ($fieldType->getFlexFormDefinitions() as $flexFormDefinition) { $dataStructure[$flexFormDefinition->getTypeName()] = $this->flexFormGenerator->generate($flexFormDefinition); } - $fieldConfiguration->setDataStructure($dataStructure); + $fieldType->setDataStructure($dataStructure); } if ($tableDefinition->hasTypeField()) { $tca['columns'][$column->getUniqueIdentifier()] = $this->getColumnTcaForTableWithTypeField($tableDefinition, $column, $baseTca); @@ -455,7 +455,9 @@ protected function getColumnsOverrides(ContentTypeInterface $typeDefinition, Tab */ protected function addUseSortableIfEnabled(TcaFieldDefinition $overrideColumn, TableDefinition $tableDefinition, array $overrideTca): array { - if ($overrideColumn->getFieldType() !== FieldType::COLLECTION) { + $fieldTypeName = $overrideColumn->getFieldType()->getName(); + $fieldTypeEnum = FieldType::tryFrom($fieldTypeName); + if ($fieldTypeEnum !== FieldType::COLLECTION) { return $overrideTca; } $tcaFieldDefinition = $tableDefinition->getTcaFieldDefinitionCollection() @@ -494,7 +496,7 @@ protected function getColumnTcaForTableWithTypeField(TableDefinition $tableDefin if ($optionKey === null) { continue; } - if (array_key_exists($optionKey, $column->getTca()['config'])) { + if (array_key_exists($optionKey, ($column->getTca()['config'] ?? []))) { $configuration = $column->getTca()['config'][$optionKey]; // Support for existing flexForm fields. if ($optionKey === 'ds') { @@ -555,8 +557,10 @@ protected function getOptionKey(string|array $option, TcaFieldDefinition $tcaFie if (is_string($option)) { return $option; } - $fieldType = FieldType::from($option['type']); - if ($fieldType === $tcaFieldDefinition->getFieldType()) { + $fieldTypeName = $tcaFieldDefinition->getFieldType()->getName(); + $currentFieldType = FieldType::tryFrom($fieldTypeName); + $fieldTypeFromOption = FieldType::tryFrom($option['type']); + if ($fieldTypeFromOption === $currentFieldType) { return $option['option']; } return null; @@ -578,7 +582,7 @@ protected function determineLabelAndDescription(ContentTypeInterface $typeDefini $column['description'] = $descriptionPath; } $fieldType = $overrideColumn->getFieldType(); - if ($fieldType->hasItems()) { + if ($fieldType::hasItems()) { $items = $column['config']['items'] ?? []; foreach ($items as $index => $item) { $labelPath = $item['labelPath']; @@ -661,7 +665,10 @@ protected function resolveLabelField(TableDefinition $tableDefinition): string // These are preferred, as they most often provide a meaningful preview of the record. $preferredLabelTypes = [FieldType::TEXT, FieldType::TEXTAREA, FieldType::EMAIL, FieldType::UUID]; foreach ($tableDefinition->getTcaFieldDefinitionCollection() as $columnFieldDefinition) { - if (in_array($columnFieldDefinition->getFieldType(), $preferredLabelTypes, true)) { + $fieldType = $columnFieldDefinition->getFieldType(); + $fieldTypeName = $fieldType::getName(); + $fieldTypeEnum = FieldType::tryFrom($fieldTypeName); + if (in_array($fieldTypeEnum, $preferredLabelTypes, true)) { $labelField = $columnFieldDefinition; break; } diff --git a/Classes/Schema/Capability/FieldCapability.php b/Classes/Schema/Capability/FieldCapability.php index 436eefe3..b3d9aa7c 100644 --- a/Classes/Schema/Capability/FieldCapability.php +++ b/Classes/Schema/Capability/FieldCapability.php @@ -17,7 +17,7 @@ namespace TYPO3\CMS\ContentBlocks\Schema\Capability; -use TYPO3\CMS\ContentBlocks\Schema\Field\FieldTypeInterface; +use TYPO3\CMS\ContentBlocks\Schema\Field\TcaFieldTypeInterface; /** * @internal Not part of TYPO3's public API. @@ -25,7 +25,7 @@ final class FieldCapability implements SchemaCapabilityInterface { public function __construct( - protected readonly FieldTypeInterface $field + protected readonly TcaFieldTypeInterface $field ) {} public function getFieldName(): string diff --git a/Classes/Schema/Capability/LanguageAwareSchemaCapability.php b/Classes/Schema/Capability/LanguageAwareSchemaCapability.php index c5e3853e..2ac35754 100644 --- a/Classes/Schema/Capability/LanguageAwareSchemaCapability.php +++ b/Classes/Schema/Capability/LanguageAwareSchemaCapability.php @@ -17,7 +17,7 @@ namespace TYPO3\CMS\ContentBlocks\Schema\Capability; -use TYPO3\CMS\ContentBlocks\Schema\Field\FieldTypeInterface; +use TYPO3\CMS\ContentBlocks\Schema\Field\TcaFieldTypeInterface; /** * Contains all information if a schema is language-aware, meaning @@ -29,18 +29,18 @@ class LanguageAwareSchemaCapability implements SchemaCapabilityInterface { public function __construct( - protected readonly FieldTypeInterface $languageField, - protected readonly FieldTypeInterface $originPointerField, - protected readonly ?FieldTypeInterface $translationSourceField, - protected readonly ?FieldTypeInterface $diffSourceField + protected readonly TcaFieldTypeInterface $languageField, + protected readonly TcaFieldTypeInterface $originPointerField, + protected readonly ?TcaFieldTypeInterface $translationSourceField, + protected readonly ?TcaFieldTypeInterface $diffSourceField ) {} - public function getLanguageField(): FieldTypeInterface + public function getLanguageField(): TcaFieldTypeInterface { return $this->languageField; } - public function getTranslationOriginPointerField(): FieldTypeInterface + public function getTranslationOriginPointerField(): TcaFieldTypeInterface { return $this->originPointerField; } @@ -50,12 +50,12 @@ public function hasTranslationSourceField(): bool return $this->translationSourceField !== null; } - public function getTranslationSourceField(): ?FieldTypeInterface + public function getTranslationSourceField(): ?TcaFieldTypeInterface { return $this->translationSourceField; } - public function getDiffSourceField(): ?FieldTypeInterface + public function getDiffSourceField(): ?TcaFieldTypeInterface { return $this->diffSourceField; } diff --git a/Classes/Schema/Field/FieldCollection.php b/Classes/Schema/Field/FieldCollection.php index 5bd83445..b0b4d4a8 100644 --- a/Classes/Schema/Field/FieldCollection.php +++ b/Classes/Schema/Field/FieldCollection.php @@ -24,7 +24,7 @@ final class FieldCollection implements \ArrayAccess, \IteratorAggregate, \Counta { public function __construct( /** - * @var array $fieldDefinitions + * @var array $fieldDefinitions */ protected array $fieldDefinitions = [] ) {} @@ -34,7 +34,7 @@ public function offsetExists(mixed $offset): bool return isset($this->fieldDefinitions[$offset]); } - public function offsetGet(mixed $offset): ?FieldTypeInterface + public function offsetGet(mixed $offset): ?TcaFieldTypeInterface { return $this->fieldDefinitions[$offset] ?? null; } @@ -50,7 +50,7 @@ public function offsetUnset(mixed $offset): void } /** - * @return \Traversable|FieldTypeInterface[] + * @return \Traversable|TcaFieldTypeInterface[] */ public function getIterator(): \Traversable { diff --git a/Classes/Schema/Field/TcaField.php b/Classes/Schema/Field/TcaField.php index 748a6bff..e60013a0 100644 --- a/Classes/Schema/Field/TcaField.php +++ b/Classes/Schema/Field/TcaField.php @@ -17,20 +17,20 @@ namespace TYPO3\CMS\ContentBlocks\Schema\Field; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeInterface; /** * @internal Not part of TYPO3's public API. */ -final class TcaField implements FieldTypeInterface +final class TcaField implements TcaFieldTypeInterface { public function __construct( - private readonly FieldType $fieldType, + private readonly FieldTypeInterface $fieldType, private readonly string $name, private readonly array $columnConfig, ) {} - public function getType(): FieldType + public function getType(): FieldTypeInterface { return $this->fieldType; } diff --git a/Classes/Schema/Field/FieldTypeInterface.php b/Classes/Schema/Field/TcaFieldTypeInterface.php similarity index 82% rename from Classes/Schema/Field/FieldTypeInterface.php rename to Classes/Schema/Field/TcaFieldTypeInterface.php index 02e66e2a..88a5024d 100644 --- a/Classes/Schema/Field/FieldTypeInterface.php +++ b/Classes/Schema/Field/TcaFieldTypeInterface.php @@ -17,14 +17,14 @@ namespace TYPO3\CMS\ContentBlocks\Schema\Field; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeInterface; /** * @internal Not part of TYPO3's public API. */ -interface FieldTypeInterface +interface TcaFieldTypeInterface { - public function getType(): FieldType; + public function getType(): FieldTypeInterface; public function getName(): string; public function getColumnConfig(): array; } diff --git a/Classes/Schema/TypeResolver.php b/Classes/Schema/FieldTypeResolver.php similarity index 68% rename from Classes/Schema/TypeResolver.php rename to Classes/Schema/FieldTypeResolver.php index 06c25700..672baa2d 100644 --- a/Classes/Schema/TypeResolver.php +++ b/Classes/Schema/FieldTypeResolver.php @@ -17,22 +17,28 @@ namespace TYPO3\CMS\ContentBlocks\Schema; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FieldType; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeInterface; +use TYPO3\CMS\ContentBlocks\FieldType\FieldTypeRegistry; /** * @internal Not part of TYPO3's public API. */ -class TypeResolver +class FieldTypeResolver { - public static function resolve(array $configuration): FieldType + public function __construct( + protected FieldTypeRegistry $fieldTypeRegistry, + ) { + } + + public function resolve(array $configuration): FieldTypeInterface { if ($configuration === [] || !isset($configuration['config']['type'])) { throw new \InvalidArgumentException('Tried to resolve type of non-existing field.', 1680110446); } $tcaType = $configuration['config']['type']; - foreach (FieldType::cases() as $enum) { - if ($enum->getTcaType() === $tcaType) { - return $enum; + foreach ($this->fieldTypeRegistry as $fieldType) { + if ($fieldType::getTcaType() === $tcaType) { + return $fieldType; } } throw new \InvalidArgumentException('Field type "' . $tcaType . '" is either not implemented or cannot be shared in Content Blocks.', 1680110918); diff --git a/Classes/Schema/SimpleTcaSchema.php b/Classes/Schema/SimpleTcaSchema.php index 0d765d23..7f270792 100644 --- a/Classes/Schema/SimpleTcaSchema.php +++ b/Classes/Schema/SimpleTcaSchema.php @@ -19,7 +19,7 @@ use TYPO3\CMS\ContentBlocks\Schema\Exception\UndefinedFieldException; use TYPO3\CMS\ContentBlocks\Schema\Field\FieldCollection; -use TYPO3\CMS\ContentBlocks\Schema\Field\FieldTypeInterface; +use TYPO3\CMS\ContentBlocks\Schema\Field\TcaFieldTypeInterface; /** * @internal Not part of TYPO3's public API. @@ -43,7 +43,7 @@ public function hasField(string $fieldName): bool return isset($this->fields[$fieldName]); } - public function getField(string $fieldName): FieldTypeInterface + public function getField(string $fieldName): TcaFieldTypeInterface { if (!$this->hasField($fieldName)) { throw new UndefinedFieldException('The field "' . $fieldName . '" is not defined for the TCA schema "' . $this->name . '".', 1661615151); @@ -105,7 +105,7 @@ protected function buildLanguageCapability(): Capability\LanguageAwareSchemaCapa ); } - public function getTypeField(): ?FieldTypeInterface + public function getTypeField(): ?TcaFieldTypeInterface { if (isset($this->schemaConfiguration['type']) && isset($this->fields[$this->schemaConfiguration['type']])) { return $this->fields[$this->schemaConfiguration['type']]; diff --git a/Classes/Schema/SimpleTcaSchemaFactory.php b/Classes/Schema/SimpleTcaSchemaFactory.php index 0eb4d8cf..073027af 100644 --- a/Classes/Schema/SimpleTcaSchemaFactory.php +++ b/Classes/Schema/SimpleTcaSchemaFactory.php @@ -30,8 +30,10 @@ class SimpleTcaSchemaFactory implements SingletonInterface protected array $schemas = []; protected array $tca; - public function __construct(array $tca = null) - { + public function __construct( + protected FieldTypeResolver $typeResolver, + array $tca = null + ) { $this->tca = $tca ?? $GLOBALS['TCA'] ?? []; foreach (array_keys($this->tca) as $table) { $this->schemas[$table] = $this->build($table); @@ -58,7 +60,7 @@ protected function build(string $schemaName): SimpleTcaSchema $schemaDefinition = $this->tca[$schemaName]; foreach ($schemaDefinition['columns'] ?? [] as $columnName => $columnConfig) { try { - $fieldType = TypeResolver::resolve($columnConfig); + $fieldType = $this->typeResolver->resolve($columnConfig); } catch (\InvalidArgumentException) { continue; } diff --git a/Classes/ServiceProvider.php b/Classes/ServiceProvider.php index 0e75abb8..23bf4334 100644 --- a/Classes/ServiceProvider.php +++ b/Classes/ServiceProvider.php @@ -278,7 +278,7 @@ public static function getContentBlockParentFieldNames(ContainerInterface $conta $fieldNames = []; $contentElementTableDefinition = $tableDefinitionCollection->getTable($contentElementTable); foreach ($contentElementTableDefinition->getParentReferences() ?? [] as $parentReference) { - $fieldConfiguration = $parentReference->getFieldConfiguration()->getTca()['config'] ?? []; + $fieldConfiguration = $parentReference->getTca()['config'] ?? []; if (($fieldConfiguration['foreign_table'] ?? '') === $contentElementTable) { $foreignField = $fieldConfiguration['foreign_field']; $fieldNames[$foreignField] = $foreignField; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index befb1117..1bc3b274 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -105,6 +105,7 @@ services: - 'create' arguments: - '@TYPO3\CMS\ContentBlocks\Registry\ContentBlockRegistry' + - '@TYPO3\CMS\ContentBlocks\FieldType\FieldTypeRegistry' - '@TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory' TYPO3\CMS\ContentBlocks\Registry\AutomaticLanguageKeysRegistry: diff --git a/Tests/Unit/FieldTypes/CategoryFieldConfigurationTest.php b/Tests/Unit/FieldTypes/CategoryFieldConfigurationTest.php index bf5df45c..961bf297 100644 --- a/Tests/Unit/FieldTypes/CategoryFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/CategoryFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\CategoryFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\CategoryFieldConfiguration; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class CategoryFieldConfigurationTest extends UnitTestCase diff --git a/Tests/Unit/FieldTypes/CheckboxFieldConfigurationTest.php b/Tests/Unit/FieldTypes/CheckboxFieldConfigurationTest.php index 13263da9..91bf88f4 100644 --- a/Tests/Unit/FieldTypes/CheckboxFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/CheckboxFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\CheckboxFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\CheckboxFieldConfiguration; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class CheckboxFieldConfigurationTest extends UnitTestCase diff --git a/Tests/Unit/FieldTypes/CollectionFieldConfigurationTest.php b/Tests/Unit/FieldTypes/CollectionFieldConfigurationTest.php index 5bf86b69..d438f4a6 100644 --- a/Tests/Unit/FieldTypes/CollectionFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/CollectionFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\CollectionFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\CollectionFieldConfiguration; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class CollectionFieldConfigurationTest extends UnitTestCase diff --git a/Tests/Unit/FieldTypes/ColorFieldConfigurationTest.php b/Tests/Unit/FieldTypes/ColorFieldConfigurationTest.php index c088ae9b..a20687ed 100644 --- a/Tests/Unit/FieldTypes/ColorFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/ColorFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\ColorFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\ColorFieldConfiguration; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class ColorFieldConfigurationTest extends UnitTestCase diff --git a/Tests/Unit/FieldTypes/DateTimeFieldConfigurationTest.php b/Tests/Unit/FieldTypes/DateTimeFieldConfigurationTest.php index 6e0fc87b..6887010e 100644 --- a/Tests/Unit/FieldTypes/DateTimeFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/DateTimeFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\DateTimeFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\DateTimeFieldConfiguration; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class DateTimeFieldConfigurationTest extends UnitTestCase diff --git a/Tests/Unit/FieldTypes/EmailFieldConfigurationTest.php b/Tests/Unit/FieldTypes/EmailFieldConfigurationTest.php index ececffa6..741024f8 100644 --- a/Tests/Unit/FieldTypes/EmailFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/EmailFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\EmailFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\EmailFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class EmailFieldConfigurationTest extends UnitTestCase @@ -104,7 +104,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = EmailFieldConfiguration::createFromArray($config); + $fieldConfiguration = EmailFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -121,7 +121,7 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = EmailFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = EmailFieldType::createFromArray([]); self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); } diff --git a/Tests/Unit/FieldTypes/FileFieldConfigurationTest.php b/Tests/Unit/FieldTypes/FileFieldConfigurationTest.php index 3ed2bfc8..f1a42ffd 100644 --- a/Tests/Unit/FieldTypes/FileFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/FileFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FileFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\FileFieldType; use TYPO3\CMS\Core\Resource\AbstractFile; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -216,7 +216,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = FileFieldConfiguration::createFromArray($config); + $fieldConfiguration = FileFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -233,8 +233,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = FileFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = FileFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, FileFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/FlexFormFieldConfigurationTest.php b/Tests/Unit/FieldTypes/FlexFormFieldConfigurationTest.php index cf097874..261dbce0 100644 --- a/Tests/Unit/FieldTypes/FlexFormFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/FlexFormFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FlexFormFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\FlexFormFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class FlexFormFieldConfigurationTest extends UnitTestCase @@ -64,7 +64,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = FlexFormFieldConfiguration::createFromArray($config); + $fieldConfiguration = FlexFormFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -81,8 +81,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = FlexFormFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = FlexFormFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, FlexFormFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/FolderFieldConfigurationTest.php b/Tests/Unit/FieldTypes/FolderFieldConfigurationTest.php index abc0c0bc..54a5c990 100644 --- a/Tests/Unit/FieldTypes/FolderFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/FolderFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\FolderFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\FolderFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class FolderFieldConfigurationTest extends UnitTestCase @@ -110,7 +110,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = FolderFieldConfiguration::createFromArray($config); + $fieldConfiguration = FolderFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -127,8 +127,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = FolderFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = FolderFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, FolderFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/JsonFieldConfigurationTest.php b/Tests/Unit/FieldTypes/JsonFieldConfigurationTest.php index aa4fabcb..f69bae87 100644 --- a/Tests/Unit/FieldTypes/JsonFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/JsonFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\JsonFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\JsonFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class JsonFieldConfigurationTest extends UnitTestCase @@ -92,7 +92,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = JsonFieldConfiguration::createFromArray($config); + $fieldConfiguration = JsonFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -109,8 +109,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = JsonFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = JsonFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, JsonFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/LanguageFieldConfigurationTest.php b/Tests/Unit/FieldTypes/LanguageFieldConfigurationTest.php index e37bf74d..92b856b3 100644 --- a/Tests/Unit/FieldTypes/LanguageFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/LanguageFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\LanguageFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\LanguageFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class LanguageFieldConfigurationTest extends UnitTestCase @@ -78,7 +78,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = LanguageFieldConfiguration::createFromArray($config); + $fieldConfiguration = LanguageFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -95,8 +95,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = LanguageFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = LanguageFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, LanguageFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/LinkFieldConfigurationTest.php b/Tests/Unit/FieldTypes/LinkFieldConfigurationTest.php index d85a21c2..068d0520 100644 --- a/Tests/Unit/FieldTypes/LinkFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/LinkFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\LinkFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\LinkFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class LinkFieldConfigurationTest extends UnitTestCase @@ -130,7 +130,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = LinkFieldConfiguration::createFromArray($config); + $fieldConfiguration = LinkFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -147,7 +147,7 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = LinkFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = LinkFieldType::createFromArray([]); self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); } diff --git a/Tests/Unit/FieldTypes/NumberFieldConfigurationTest.php b/Tests/Unit/FieldTypes/NumberFieldConfigurationTest.php index fad52436..6cb8e099 100644 --- a/Tests/Unit/FieldTypes/NumberFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/NumberFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\NumberFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\NumberFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class NumberFieldConfigurationTest extends UnitTestCase @@ -166,7 +166,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = NumberFieldConfiguration::createFromArray($config); + $fieldConfiguration = NumberFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -191,7 +191,7 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(array $config, string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = NumberFieldConfiguration::createFromArray($config); + $inputFieldConfiguration = NumberFieldType::createFromArray($config); self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); } diff --git a/Tests/Unit/FieldTypes/PasswordFieldConfigurationTest.php b/Tests/Unit/FieldTypes/PasswordFieldConfigurationTest.php index 82a82101..fd229cba 100644 --- a/Tests/Unit/FieldTypes/PasswordFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/PasswordFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\PasswordFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\PasswordFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class PasswordFieldConfigurationTest extends UnitTestCase @@ -109,7 +109,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = PasswordFieldConfiguration::createFromArray($config); + $fieldConfiguration = PasswordFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -126,7 +126,7 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = PasswordFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = PasswordFieldType::createFromArray([]); self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); } diff --git a/Tests/Unit/FieldTypes/RadioFieldConfigurationTest.php b/Tests/Unit/FieldTypes/RadioFieldConfigurationTest.php index da36a74d..153cdc33 100644 --- a/Tests/Unit/FieldTypes/RadioFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/RadioFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\RadioFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\RadioFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class RadioFieldConfigurationTest extends UnitTestCase @@ -100,7 +100,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = RadioFieldConfiguration::createFromArray($config); + $fieldConfiguration = RadioFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -117,8 +117,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = RadioFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = RadioFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, RadioFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/RelationFieldConfigurationTest.php b/Tests/Unit/FieldTypes/RelationFieldConfigurationTest.php index 3e419266..35c15d01 100644 --- a/Tests/Unit/FieldTypes/RelationFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/RelationFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\RelationFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\RelationFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class RelationFieldConfigurationTest extends UnitTestCase @@ -189,7 +189,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = RelationFieldConfiguration::createFromArray($config); + $fieldConfiguration = RelationFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -206,8 +206,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = RelationFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = RelationFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, RelationFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/SelectFieldConfigurationTest.php b/Tests/Unit/FieldTypes/SelectFieldConfigurationTest.php index 82020505..f4d0b1f0 100644 --- a/Tests/Unit/FieldTypes/SelectFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/SelectFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\SelectFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\SelectFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class SelectFieldConfigurationTest extends UnitTestCase @@ -194,7 +194,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = SelectFieldConfiguration::createFromArray($config); + $fieldConfiguration = SelectFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -211,8 +211,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = SelectFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = SelectFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, SelectFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/SlugFieldConfigurationTest.php b/Tests/Unit/FieldTypes/SlugFieldConfigurationTest.php index a39a239e..4e474744 100644 --- a/Tests/Unit/FieldTypes/SlugFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/SlugFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\SlugFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\SlugFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class SlugFieldConfigurationTest extends UnitTestCase @@ -105,7 +105,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = SlugFieldConfiguration::createFromArray($config); + $fieldConfiguration = SlugFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -122,8 +122,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = SlugFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = SlugFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, FieldTypeInterface::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/TextFieldConfigurationTest.php b/Tests/Unit/FieldTypes/TextFieldConfigurationTest.php index 666972dc..cdec9432 100644 --- a/Tests/Unit/FieldTypes/TextFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/TextFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\TextFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\TextFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class TextFieldConfigurationTest extends UnitTestCase @@ -130,7 +130,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = TextFieldConfiguration::createFromArray($config); + $fieldConfiguration = TextFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -147,7 +147,7 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = TextFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = TextFieldType::createFromArray([]); self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); } diff --git a/Tests/Unit/FieldTypes/TextareaFieldConfigurationTest.php b/Tests/Unit/FieldTypes/TextareaFieldConfigurationTest.php index e98bb444..2e5266db 100644 --- a/Tests/Unit/FieldTypes/TextareaFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/TextareaFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\TextareaFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\TextareaFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class TextareaFieldConfigurationTest extends UnitTestCase @@ -142,7 +142,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = TextareaFieldConfiguration::createFromArray($config); + $fieldConfiguration = TextareaFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -159,8 +159,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = TextareaFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = TextareaFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, TextareaFieldType::getSql($uniqueColumnName)); } } diff --git a/Tests/Unit/FieldTypes/UuidFieldConfigurationTest.php b/Tests/Unit/FieldTypes/UuidFieldConfigurationTest.php index b6a762d2..40ffbe63 100644 --- a/Tests/Unit/FieldTypes/UuidFieldConfigurationTest.php +++ b/Tests/Unit/FieldTypes/UuidFieldConfigurationTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use TYPO3\CMS\ContentBlocks\FieldConfiguration\UuidFieldConfiguration; +use TYPO3\CMS\ContentBlocks\FieldType\UuidFieldType; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class UuidFieldConfigurationTest extends UnitTestCase @@ -85,7 +85,7 @@ public static function getTcaReturnsExpectedTcaDataProvider(): iterable #[Test] public function getTcaReturnsExpectedTca(array $config, array $expectedTca): void { - $fieldConfiguration = UuidFieldConfiguration::createFromArray($config); + $fieldConfiguration = UuidFieldType::createFromArray($config); self::assertSame($expectedTca, $fieldConfiguration->getTca()); } @@ -102,8 +102,8 @@ public static function getSqlReturnsExpectedSqlDefinitionDataProvider(): iterabl #[Test] public function getSqlReturnsExpectedSqlDefinition(string $uniqueColumnName, string $expectedSql): void { - $inputFieldConfiguration = UuidFieldConfiguration::createFromArray([]); + $inputFieldConfiguration = UuidFieldType::createFromArray([]); - self::assertSame($expectedSql, $inputFieldConfiguration->getSql($uniqueColumnName)); + self::assertSame($expectedSql, UuidFieldType::getSql($uniqueColumnName)); } }