diff --git a/typo3/sysext/core/Classes/Schema/Field/AbstractFieldType.php b/typo3/sysext/core/Classes/Schema/Field/AbstractFieldType.php index ed7a1fa3371db38348d2dcd4d7a695001e004d66..b8fe411e640326d79e5ab7834021e44a7c95e970 100644 --- a/typo3/sysext/core/Classes/Schema/Field/AbstractFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/AbstractFieldType.php @@ -29,6 +29,12 @@ abstract readonly class AbstractFieldType implements FieldTypeInterface protected array $configuration, ) {} + public static function __set_state(array $state): self + { + /** @phpstan-ignore-next-line Usage is safe because state is exported by PHP var_export() from the static instance */ + return new static(...$state); + } + abstract public function getType(): string; public function getName(): string diff --git a/typo3/sysext/core/Classes/Schema/Field/CategoryFieldType.php b/typo3/sysext/core/Classes/Schema/Field/CategoryFieldType.php index 59da0b647d6e9d7aad8a5da1599e974f3cf01c5a..fb0f7feec5544b9890799acb07202a9eeff6a367 100644 --- a/typo3/sysext/core/Classes/Schema/Field/CategoryFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/CategoryFieldType.php @@ -22,12 +22,12 @@ use TYPO3\CMS\Core\Schema\RelationshipType; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class CategoryFieldType extends AbstractFieldType implements FieldTypeInterface, RelationalFieldTypeInterface +final readonly class CategoryFieldType extends AbstractFieldType implements RelationalFieldTypeInterface { public function __construct( protected string $name, protected array $configuration, - protected array $relations, + protected array $relations ) {} public function getType(): string @@ -35,6 +35,11 @@ final readonly class CategoryFieldType extends AbstractFieldType implements Fiel return 'category'; } + public function getTreeConfiguration(): array + { + return $this->configuration['treeConfig'] ?? []; + } + public function getRelations(): array { return $this->relations; @@ -44,9 +49,4 @@ final readonly class CategoryFieldType extends AbstractFieldType implements Fiel { return RelationshipType::fromTcaConfiguration($this->configuration); } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/CheckboxFieldType.php b/typo3/sysext/core/Classes/Schema/Field/CheckboxFieldType.php index 423aeca59ba20de63024c8734fd9c47952bd4567..6b83056a7507a19fd647190bdadd1cf256d4491e 100644 --- a/typo3/sysext/core/Classes/Schema/Field/CheckboxFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/CheckboxFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class CheckboxFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class CheckboxFieldType extends AbstractFieldType { public function getType(): string { return 'check'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/ColorFieldType.php b/typo3/sysext/core/Classes/Schema/Field/ColorFieldType.php index 335fe8342d9fcfb6f6fe9078dfceb0ee120d7b68..eafb6c7c7df750a0da389ddffc461a921039f95e 100644 --- a/typo3/sysext/core/Classes/Schema/Field/ColorFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/ColorFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class ColorFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class ColorFieldType extends AbstractFieldType { public function getType(): string { return 'color'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/DateTimeFieldType.php b/typo3/sysext/core/Classes/Schema/Field/DateTimeFieldType.php index 18e1824b83c12611a69298c58bf2a61ff3ebc21d..b46459799f966167e5c8dfd361d6c7e82847e7eb 100644 --- a/typo3/sysext/core/Classes/Schema/Field/DateTimeFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/DateTimeFieldType.php @@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Database\Query\QueryHelper; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class DateTimeFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class DateTimeFieldType extends AbstractFieldType { public function getType(): string { @@ -38,14 +38,4 @@ final readonly class DateTimeFieldType extends AbstractFieldType implements Fiel { return in_array($this->configuration['dbType'] ?? null, QueryHelper::getDateTimeTypes(), true) ? $this->configuration['dbType'] : null; } - - public function isNullable(): bool - { - return (bool)($this->configuration['nullable'] ?? false); - } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/EmailFieldType.php b/typo3/sysext/core/Classes/Schema/Field/EmailFieldType.php index 9012ea0616d524102ede0b29252f36627fe01738..413f14517c482d9cefc57dc5de129c858c89a7fb 100644 --- a/typo3/sysext/core/Classes/Schema/Field/EmailFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/EmailFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class EmailFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class EmailFieldType extends AbstractFieldType { public function getType(): string { return 'email'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/FieldCollection.php b/typo3/sysext/core/Classes/Schema/Field/FieldCollection.php index e462968130aeadb2c31dd4a528b71e52aeb7538e..1f7fabfa342b32ad74ab090af5be962f0d56042c 100644 --- a/typo3/sysext/core/Classes/Schema/Field/FieldCollection.php +++ b/typo3/sysext/core/Classes/Schema/Field/FieldCollection.php @@ -29,6 +29,11 @@ final readonly class FieldCollection implements \ArrayAccess, \IteratorAggregate protected array $fieldDefinitions = [] ) {} + public static function __set_state(array $state): self + { + return new self(...$state); + } + public function offsetExists(mixed $offset): bool { return isset($this->fieldDefinitions[$offset]); @@ -61,9 +66,4 @@ final readonly class FieldCollection implements \ArrayAccess, \IteratorAggregate { return count($this->fieldDefinitions); } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/FileFieldType.php b/typo3/sysext/core/Classes/Schema/Field/FileFieldType.php index 15449a7055065522f08938a1bea20dd47a210f6a..d4e2973f3b14c66d18372f8a570a206ce33debfd 100644 --- a/typo3/sysext/core/Classes/Schema/Field/FileFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/FileFieldType.php @@ -18,6 +18,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Schema\Field; use TYPO3\CMS\Core\Schema\RelationshipType; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** * This is a field to a "file" (which is very similar to "inline") but with a hard-coded @@ -25,7 +26,7 @@ use TYPO3\CMS\Core\Schema\RelationshipType; * * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class FileFieldType extends AbstractFieldType implements FieldTypeInterface, RelationalFieldTypeInterface +final readonly class FileFieldType extends AbstractFieldType implements RelationalFieldTypeInterface { public function __construct( protected string $name, @@ -38,6 +39,20 @@ final readonly class FileFieldType extends AbstractFieldType implements FieldTyp return 'file'; } + public function getAllowedFileExtensions(): array + { + return is_array($this->configuration['allowed'] ?? null) + ? $this->configuration['allowed'] + : GeneralUtility::trimExplode(',', $this->configuration['allowed'] ?? '', true); + } + + public function getDisallowedFileExtensions(): array + { + return is_array($this->configuration['disallowed'] ?? null) + ? $this->configuration['disallowed'] + : GeneralUtility::trimExplode(',', $this->configuration['disallowed'] ?? '', true); + } + public function getRelations(): array { return $this->relations; @@ -47,9 +62,4 @@ final readonly class FileFieldType extends AbstractFieldType implements FieldTyp { return RelationshipType::fromTcaConfiguration($this->configuration); } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/FlexFormFieldType.php b/typo3/sysext/core/Classes/Schema/Field/FlexFormFieldType.php index 0f9452fe0f3ec31c2ab1e96e7d18cbe8d240dcc6..e16c068bc7ecfbef4bb6efc56ea98a84d11ac191 100644 --- a/typo3/sysext/core/Classes/Schema/Field/FlexFormFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/FlexFormFieldType.php @@ -20,20 +20,15 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class FlexFormFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class FlexFormFieldType extends AbstractFieldType { - public function __construct( - protected string $name, - protected array $configuration, - ) {} - public function getType(): string { return 'flex'; } - public static function __set_state(array $state): self + public function getDataStructure(): array { - return new self(...$state); + return is_array($this->configuration['ds'] ?? null) ? $this->configuration['ds'] : []; } } diff --git a/typo3/sysext/core/Classes/Schema/Field/FolderFieldType.php b/typo3/sysext/core/Classes/Schema/Field/FolderFieldType.php index 9c39e454800e894b2e0b202b6adb6076b1f6d143..c9248594db89b306dc124af34dcb1e66de4ddde3 100644 --- a/typo3/sysext/core/Classes/Schema/Field/FolderFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/FolderFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class FolderFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class FolderFieldType extends AbstractFieldType { public function getType(): string { return 'folder'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/GroupFieldType.php b/typo3/sysext/core/Classes/Schema/Field/GroupFieldType.php index e6ffa69fac064cb3636678b0667e8270e4e0032a..c46d4d25b4503815e006eac56b9301ef1395d91f 100644 --- a/typo3/sysext/core/Classes/Schema/Field/GroupFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/GroupFieldType.php @@ -22,7 +22,7 @@ use TYPO3\CMS\Core\Schema\RelationshipType; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class GroupFieldType extends AbstractFieldType implements FieldTypeInterface, RelationalFieldTypeInterface +final readonly class GroupFieldType extends AbstractFieldType implements RelationalFieldTypeInterface { public function __construct( protected string $name, @@ -44,9 +44,4 @@ final readonly class GroupFieldType extends AbstractFieldType implements FieldTy { return RelationshipType::fromTcaConfiguration($this->configuration); } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/ImageManipulationFieldType.php b/typo3/sysext/core/Classes/Schema/Field/ImageManipulationFieldType.php index 31da630864b65cfd825d2c3a2a43d7c3696354eb..a003e285bb589539ea5bd7a208cf945b06e750c4 100644 --- a/typo3/sysext/core/Classes/Schema/Field/ImageManipulationFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/ImageManipulationFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class ImageManipulationFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class ImageManipulationFieldType extends AbstractFieldType { public function getType(): string { return 'imageManipulation'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/InlineFieldType.php b/typo3/sysext/core/Classes/Schema/Field/InlineFieldType.php index f36021e5438503efad59cbe1c9543eac38690b4f..140a4a1aea80cb13ae67fd4b2ccdb3029f06ec8f 100644 --- a/typo3/sysext/core/Classes/Schema/Field/InlineFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/InlineFieldType.php @@ -24,12 +24,12 @@ use TYPO3\CMS\Core\Schema\RelationshipType; * * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class InlineFieldType extends AbstractFieldType implements FieldTypeInterface, RelationalFieldTypeInterface +final readonly class InlineFieldType extends AbstractFieldType implements RelationalFieldTypeInterface { public function __construct( protected string $name, protected array $configuration, - protected array $relations, + protected array $relations ) {} public function getType(): string @@ -51,9 +51,4 @@ final readonly class InlineFieldType extends AbstractFieldType implements FieldT { return (bool)($this->configuration['behaviour']['disableMovingChildrenWithParent'] ?? false) === false; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/InputFieldType.php b/typo3/sysext/core/Classes/Schema/Field/InputFieldType.php index 1f252b89f37d6bcfa8c93bebe19b1ed4d00b2dfb..c00516a39a32835a8188d1b0ff19ca1ff1a4ffb5 100644 --- a/typo3/sysext/core/Classes/Schema/Field/InputFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/InputFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class InputFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class InputFieldType extends AbstractFieldType { public function getType(): string { return 'input'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/JsonFieldType.php b/typo3/sysext/core/Classes/Schema/Field/JsonFieldType.php index 72a4a1b5ed593285d55031166d2911274833659d..815f9ae3bda95ec89e9a2a360dac3c8abc339927 100644 --- a/typo3/sysext/core/Classes/Schema/Field/JsonFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/JsonFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class JsonFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class JsonFieldType extends AbstractFieldType { public function getType(): string { return 'json'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/LanguageFieldType.php b/typo3/sysext/core/Classes/Schema/Field/LanguageFieldType.php index 5b695b2f739f0112b43650c3033422d8cf08c0f6..ba0d524f0ad77ffcd94cfdd64af2d48a469a492e 100644 --- a/typo3/sysext/core/Classes/Schema/Field/LanguageFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/LanguageFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class LanguageFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class LanguageFieldType extends AbstractFieldType { public function getType(): string { return 'language'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/LinkFieldType.php b/typo3/sysext/core/Classes/Schema/Field/LinkFieldType.php index 20622191425230fbae4bc1ff3d6a5bce6851e6d5..d42a8a8615c166c2b3e71d8f80de1edf54f8894f 100644 --- a/typo3/sysext/core/Classes/Schema/Field/LinkFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/LinkFieldType.php @@ -20,7 +20,7 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class LinkFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class LinkFieldType extends AbstractFieldType { public function getType(): string { @@ -31,9 +31,4 @@ final readonly class LinkFieldType extends AbstractFieldType implements FieldTyp { return $this->configuration['allowedTypes'] ?? ['*']; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/NoneFieldType.php b/typo3/sysext/core/Classes/Schema/Field/NoneFieldType.php index a64783c5e21db9ce118bdfce1cd5173fbf41ef86..caf5283bfd8fffee0b31b8d7aa1e2fdf99effced 100644 --- a/typo3/sysext/core/Classes/Schema/Field/NoneFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/NoneFieldType.php @@ -17,18 +17,20 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Schema\Field; +use TYPO3\CMS\Core\Schema\FieldFormat; + /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class NoneFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class NoneFieldType extends AbstractFieldType { public function getType(): string { return 'none'; } - public static function __set_state(array $state): self + public function getFormat(): FieldFormat { - return new self(...$state); + return FieldFormat::fromTcaConfiguration($this->configuration); } } diff --git a/typo3/sysext/core/Classes/Schema/Field/NumberFieldType.php b/typo3/sysext/core/Classes/Schema/Field/NumberFieldType.php index d41866864e39e2dfcac1d49c9fb5214dae268abb..051bf8263f6c433a4e719942f13d02c8e353ebf8 100644 --- a/typo3/sysext/core/Classes/Schema/Field/NumberFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/NumberFieldType.php @@ -20,7 +20,7 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class NumberFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class NumberFieldType extends AbstractFieldType { public function getType(): string { @@ -31,9 +31,4 @@ final readonly class NumberFieldType extends AbstractFieldType implements FieldT { return $this->configuration['format'] ?? ''; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/PassthroughFieldType.php b/typo3/sysext/core/Classes/Schema/Field/PassthroughFieldType.php index e309344375be245b713637efcebf0949abc8ec52..ddbad6ee82b1d32c4d32b4d70aee67f0552ba622 100644 --- a/typo3/sysext/core/Classes/Schema/Field/PassthroughFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/PassthroughFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class PassthroughFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class PassthroughFieldType extends AbstractFieldType { public function getType(): string { return 'passthrough'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/PasswordFieldType.php b/typo3/sysext/core/Classes/Schema/Field/PasswordFieldType.php index 318b654ae67543eff8c3aaaec4e8e1021a46fa97..85c5fdf9c470709a5273be5c8db7004424267355 100644 --- a/typo3/sysext/core/Classes/Schema/Field/PasswordFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/PasswordFieldType.php @@ -20,7 +20,7 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class PasswordFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class PasswordFieldType extends AbstractFieldType { public function getType(): string { @@ -31,9 +31,4 @@ final readonly class PasswordFieldType extends AbstractFieldType implements Fiel { return $this->configuration['hashed'] ?? true; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/RadioFieldType.php b/typo3/sysext/core/Classes/Schema/Field/RadioFieldType.php index 32b63d576d0868c28bec526dfeec72cff0092a8f..ec39a06d501db3aaadafa233667b4b36d0beb9ca 100644 --- a/typo3/sysext/core/Classes/Schema/Field/RadioFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/RadioFieldType.php @@ -20,15 +20,10 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class RadioFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class RadioFieldType extends AbstractFieldType { public function getType(): string { return 'radio'; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/SelectRelationFieldType.php b/typo3/sysext/core/Classes/Schema/Field/SelectRelationFieldType.php index d43dd66cba2a23ca12601b28ab6192f415b5d3aa..c633af078398e5ee5259d3ca0c17a86e208ae8fa 100644 --- a/typo3/sysext/core/Classes/Schema/Field/SelectRelationFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/SelectRelationFieldType.php @@ -24,7 +24,7 @@ use TYPO3\CMS\Core\Schema\RelationshipType; * * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class SelectRelationFieldType extends AbstractFieldType implements FieldTypeInterface, RelationalFieldTypeInterface +final readonly class SelectRelationFieldType extends AbstractFieldType implements RelationalFieldTypeInterface { public function __construct( protected string $name, @@ -46,9 +46,4 @@ final readonly class SelectRelationFieldType extends AbstractFieldType implement { return RelationshipType::fromTcaConfiguration($this->configuration); } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/SlugFieldType.php b/typo3/sysext/core/Classes/Schema/Field/SlugFieldType.php index e2998a99b8cf0c92a39a45a857e07a608b805005..0cb5c678b9c467b3719ddf97b1414dfcf64d121e 100644 --- a/typo3/sysext/core/Classes/Schema/Field/SlugFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/SlugFieldType.php @@ -20,15 +20,20 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class SlugFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class SlugFieldType extends AbstractFieldType { public function getType(): string { return 'slug'; } - public static function __set_state(array $state): self + public function getGeneratorOption(string $optionName): array|string|bool|null { - return new self(...$state); + return $this->configuration['generatorOptions'][$optionName] ?? null; + } + + public function getGeneratorOptions(): array + { + return is_array($this->configuration['generatorOptions']) ? $this->configuration['generatorOptions'] : []; } } diff --git a/typo3/sysext/core/Classes/Schema/Field/StaticSelectFieldType.php b/typo3/sysext/core/Classes/Schema/Field/StaticSelectFieldType.php index a12f0a06eaf5c01ad4eec9ad8d2d50fe046dc5fc..65c1c829a04da386ddf536fdd12eac023051b25c 100644 --- a/typo3/sysext/core/Classes/Schema/Field/StaticSelectFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/StaticSelectFieldType.php @@ -17,20 +17,28 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Schema\Field; +use TYPO3\CMS\Core\Schema\Struct\SelectItem; + /** * This is a select type without any MM or foreign table logic. * * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class StaticSelectFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class StaticSelectFieldType extends AbstractFieldType { public function getType(): string { return 'select'; } - public static function __set_state(array $state): self + /** + * @return SelectItem[] + */ + public function getItems(): array { - return new self(...$state); + return is_array($this->configuration['items'] ?? false) ? array_map( + static fn($item): SelectItem => SelectItem::fromTcaItemArray($item), + $this->configuration['items'] + ) : []; } } diff --git a/typo3/sysext/core/Classes/Schema/Field/TextFieldType.php b/typo3/sysext/core/Classes/Schema/Field/TextFieldType.php index ca3a479961c4e3942a24cffbf52de8e26c78ef42..ab2c684c02d51fad919b31213f878c691c7aa246 100644 --- a/typo3/sysext/core/Classes/Schema/Field/TextFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/TextFieldType.php @@ -20,7 +20,7 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class TextFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class TextFieldType extends AbstractFieldType { public function getType(): string { @@ -31,9 +31,4 @@ final readonly class TextFieldType extends AbstractFieldType implements FieldTyp { return $this->configuration['enableRichtext'] ?? false; } - - public static function __set_state(array $state): self - { - return new self(...$state); - } } diff --git a/typo3/sysext/core/Classes/Schema/Field/UserFieldType.php b/typo3/sysext/core/Classes/Schema/Field/UserFieldType.php index 93ba6caa500622ded8f0b5fd2f2b98cd5aac95ca..bcb5aa70af5c71d904d353a3ad0cb7eb55124bed 100644 --- a/typo3/sysext/core/Classes/Schema/Field/UserFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/UserFieldType.php @@ -20,15 +20,15 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class UserFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class UserFieldType extends AbstractFieldType { public function getType(): string { return 'user'; } - public static function __set_state(array $state): self + public function getRenderType(): string { - return new self(...$state); + return $this->configuration['renderType'] ?? ''; } } diff --git a/typo3/sysext/core/Classes/Schema/Field/UuidFieldType.php b/typo3/sysext/core/Classes/Schema/Field/UuidFieldType.php index f8ad82a24bc7c3e89b0a4f7f965b73b9d3b9a3f7..a567ee4c49c3636cfa6e25a4fef2fd80503c28a5 100644 --- a/typo3/sysext/core/Classes/Schema/Field/UuidFieldType.php +++ b/typo3/sysext/core/Classes/Schema/Field/UuidFieldType.php @@ -20,15 +20,15 @@ namespace TYPO3\CMS\Core\Schema\Field; /** * @internal This is an experimental implementation and might change until TYPO3 v13 LTS */ -final readonly class UuidFieldType extends AbstractFieldType implements FieldTypeInterface +final readonly class UuidFieldType extends AbstractFieldType { public function getType(): string { return 'uuid'; } - public static function __set_state(array $state): self + public function getVersion(): int { - return new self(...$state); + return in_array($this->configuration['version'] ?? 0, [4, 6, 7], true) ? $this->configuration['version'] : 4; } } diff --git a/typo3/sysext/core/Classes/Schema/FieldFormat.php b/typo3/sysext/core/Classes/Schema/FieldFormat.php new file mode 100644 index 0000000000000000000000000000000000000000..305d25dd645418a09afa7fb75d4821f5039a2eac --- /dev/null +++ b/typo3/sysext/core/Classes/Schema/FieldFormat.php @@ -0,0 +1,112 @@ +<?php + +declare(strict_types=1); + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +namespace TYPO3\CMS\Core\Schema; + +/** + * @internal This is an experimental implementation and might change until TYPO3 v13 LTS + */ +enum FieldFormat: string +{ + case Date = 'date'; + + case Datetime = 'datetime'; + + case Time = 'time'; + + case Timesec = 'timesec'; + + case Year = 'year'; + + case Int = 'int'; + + case Float = 'float'; + + case Number = 'number'; + + case Md5 = 'md5'; + + case Filesize = 'filesize'; + + case User = 'user'; + + case Undefined = ''; + + private const FORMAT_CONFIGURATION = [ + self::Date->value => [ + 'strftime', + 'option', + 'appendAge', + ], + self::Int->value => [ + 'base', + ], + self::Float->value => [ + 'precision', + ], + self::Number->value => [ + 'option', + ], + self::Filesize->value => [ + 'appendByteSize', + ], + self::User->value => [ + 'userFunc', + ], + ]; + + public static function fromTcaConfiguration(array $configuration): self + { + if (isset($configuration['config'])) { + $configuration = $configuration['config']; + } + if (isset($configuration['format'])) { + return match ($configuration['format']) { + 'date' => self::Date, + 'datetime' => self::Datetime, + 'time' => self::Time, + 'timesec' => self::Timesec, + 'year' => self::Year, + 'int' => self::Int, + 'float' => self::Float, + 'number' => self::Number, + 'md5' => self::Md5, + 'filesize' => self::Filesize, + 'user' => self::User, + default => throw new \UnexpectedValueException('Invalid format: ' . $configuration['format'], 1724744407), + }; + } + + return self::Undefined; + } + + public function getFormatConfiguration(array $configuration): array + { + if (isset($configuration['config'])) { + $configuration = $configuration['config']; + } + + if (!isset(self::FORMAT_CONFIGURATION[$this->value]) + || !is_array($configuration['format.'] ?? false) + || $configuration['format.'] === [] + ) { + return []; + } + + return array_filter($configuration['format.'], fn(string $option): bool => in_array($option, self::FORMAT_CONFIGURATION[$this->value], true), ARRAY_FILTER_USE_KEY); + } +} diff --git a/typo3/sysext/core/Classes/Schema/TcaSchema.php b/typo3/sysext/core/Classes/Schema/TcaSchema.php index 739c7d15ca95da400f5b0df1bcf2f16184d852d0..e30ae41f93da26843771e94a28b2d0dad25b0f65 100644 --- a/typo3/sysext/core/Classes/Schema/TcaSchema.php +++ b/typo3/sysext/core/Classes/Schema/TcaSchema.php @@ -48,9 +48,15 @@ readonly class TcaSchema implements SchemaInterface return $this->name; } - public function getFields(): FieldCollection + public function getFields(...$fieldNames): FieldCollection { - return $this->fields; + if ($fieldNames === []) { + return $this->fields; + } + + return new FieldCollection( + array_filter(iterator_to_array($this->fields), static fn(FieldTypeInterface $field): bool => in_array($field->getName(), $fieldNames, true)) + ); } public function hasField(string $fieldName): bool diff --git a/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php b/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php index 2d9d0404c2126066b8a780ce24503262f09f3a3d..30c145cb28a0c9835d6873dc869807e467347ca4 100644 --- a/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php +++ b/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php @@ -1550,6 +1550,18 @@ backend_layout { 'format' => 'datetime', ], ], + 'none_4' => [ + 'label' => 'none_4', + 'description' => 'format=date with format configuration', + 'config' => [ + 'type' => 'none', + 'format' => 'date', + 'format.' => [ + 'option' => '%d-%m', + 'strftime' => true, + ], + ], + ], 'passthrough_1' => [ 'label' => 'passthrough_1', @@ -1914,7 +1926,7 @@ backend_layout { --div--;language, language_1, --div--;none, - none_1, none_2, none_3, + none_1, none_2, none_3, none_4, --div--;passthrough, passthrough_1, passthrough_2, --div--;user, diff --git a/typo3/sysext/styleguide/ext_tables.sql b/typo3/sysext/styleguide/ext_tables.sql index f30916b63a49b7785fd93abbe4942f32860d0cc0..6da4ac743fb929e38eb822db45495d3cae5c1ce9 100644 --- a/typo3/sysext/styleguide/ext_tables.sql +++ b/typo3/sysext/styleguide/ext_tables.sql @@ -33,6 +33,7 @@ CREATE TABLE tx_styleguide_elements_basic ( none_1 text, none_2 text, none_3 text, + none_4 text, # type=passthrough needs manual configuration passthrough_1 text,