FieldTypeFactory
Create field objects based on the TCA of the "columns" area.
A field type is a class that represents a field in a schema.
Currently, the FieldTypes are hard-coded in this class, but in the future, this might be moved into a more flexible registry.
Also, the class currently encapsulates the building of the FlexFormSchema (which in turn also has fields), however, since this has some tight coupling this resides here for the time being, but should be extracted later-on.
Some interesting points:
- the special type "select" is separated into two different classes - one with relations, and one without.
This is an experimental implementation and might change until TYPO3 v13 LTS
Table of Contents
Properties
- $availableFieldTypes : array<string, FieldTypeInterface>>
Methods
- createFieldType() : FieldTypeInterface
- createFlexFormField() : FlexFormFieldType
- First, parse the data structures (and if we only have a subschema, we use that one, ofc)
- createFromTca() : FieldTypeInterface
- Basic factory to create the field type from the TCA configuration via new().
- hasFieldType() : bool
- streamlineFieldConfiguration() : array<string|int, mixed>
- Removes the "config" subkey from TCA, to make it easier to work with the configuration array, also makes caching smaller.
Properties
$availableFieldTypes
protected
array<string, FieldTypeInterface>>
$availableFieldTypes
= ['category' => \TYPO3\CMS\Core\Schema\Field\CategoryFieldType::class, 'check' => \TYPO3\CMS\Core\Schema\Field\CheckboxFieldType::class, 'color' => \TYPO3\CMS\Core\Schema\Field\ColorFieldType::class, 'datetime' => \TYPO3\CMS\Core\Schema\Field\DateTimeFieldType::class, 'email' => \TYPO3\CMS\Core\Schema\Field\EmailFieldType::class, 'file' => \TYPO3\CMS\Core\Schema\Field\FileFieldType::class, 'flex' => \TYPO3\CMS\Core\Schema\Field\FlexFormFieldType::class, 'folder' => \TYPO3\CMS\Core\Schema\Field\FolderFieldType::class, 'group' => \TYPO3\CMS\Core\Schema\Field\GroupFieldType::class, 'imageManipulation' => \TYPO3\CMS\Core\Schema\Field\ImageManipulationFieldType::class, 'inline' => \TYPO3\CMS\Core\Schema\Field\InlineFieldType::class, 'input' => \TYPO3\CMS\Core\Schema\Field\InputFieldType::class, 'json' => \TYPO3\CMS\Core\Schema\Field\JsonFieldType::class, 'language' => \TYPO3\CMS\Core\Schema\Field\LanguageFieldType::class, 'link' => \TYPO3\CMS\Core\Schema\Field\LinkFieldType::class, 'none' => \TYPO3\CMS\Core\Schema\Field\NoneFieldType::class, 'number' => \TYPO3\CMS\Core\Schema\Field\NumberFieldType::class, 'passthrough' => \TYPO3\CMS\Core\Schema\Field\PassthroughFieldType::class, 'password' => \TYPO3\CMS\Core\Schema\Field\PasswordFieldType::class, 'radio' => \TYPO3\CMS\Core\Schema\Field\RadioFieldType::class, 'slug' => \TYPO3\CMS\Core\Schema\Field\SlugFieldType::class, 'text' => \TYPO3\CMS\Core\Schema\Field\TextFieldType::class, 'user' => \TYPO3\CMS\Core\Schema\Field\UserFieldType::class, 'uuid' => \TYPO3\CMS\Core\Schema\Field\UuidFieldType::class]
Methods
createFieldType()
public
createFieldType(string $fieldName, array<string|int, mixed> $configuration, string $schemaName, RelationMap $relationMap[, string|null $parentSchemaName = null ][, string|null $parentFieldName = null ]) : FieldTypeInterface
Parameters
- $fieldName : string
- $configuration : array<string|int, mixed>
- $schemaName : string
- $relationMap : RelationMap
- $parentSchemaName : string|null = null
- $parentFieldName : string|null = null
Return values
FieldTypeInterfacecreateFlexFormField()
First, parse the data structures (and if we only have a subschema, we use that one, ofc)
protected
createFlexFormField(string $mainSchemaName, string $fieldName, array<string|int, mixed> $tcaConfig, RelationMap $relationMap[, string|null $subSchemaName = null ]) : FlexFormFieldType
Parameters
- $mainSchemaName : string
- $fieldName : string
- $tcaConfig : array<string|int, mixed>
- $relationMap : RelationMap
- $subSchemaName : string|null = null
Return values
FlexFormFieldTypecreateFromTca()
Basic factory to create the field type from the TCA configuration via new().
protected
createFromTca(string $targetClass, string $fieldName, array<string|int, mixed> $fieldConfiguration[, array<string|int, mixed>|null $relations = null ]) : FieldTypeInterface
Parameters
- $targetClass : string
- $fieldName : string
- $fieldConfiguration : array<string|int, mixed>
- $relations : array<string|int, mixed>|null = null
Return values
FieldTypeInterfacehasFieldType()
protected
hasFieldType(string $fieldType) : bool
Parameters
- $fieldType : string
Return values
boolstreamlineFieldConfiguration()
Removes the "config" subkey from TCA, to make it easier to work with the configuration array, also makes caching smaller.
protected
streamlineFieldConfiguration(array<string|int, mixed> $fieldConfiguration) : array<string|int, mixed>
Parameters
- $fieldConfiguration : array<string|int, mixed>