diff --git a/core/lib/Drupal/Core/Field/Attribute/FieldType.php b/core/lib/Drupal/Core/Field/Attribute/FieldType.php new file mode 100644 index 0000000000000000000000000000000000000000..2a2196f51ef5759943de0b56f5f4f0d5f148ce2a --- /dev/null +++ b/core/lib/Drupal/Core/Field/Attribute/FieldType.php @@ -0,0 +1,87 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Core\Field\Attribute; + +use Drupal\Component\Plugin\Attribute\Plugin; +use Drupal\Core\StringTranslation\TranslatableMarkup; + +/** + * Defines a FieldType attribute. + * + * Additional attribute keys for field types can be defined in + * hook_field_info_alter(). + * + * @ingroup field_types + */ +#[\Attribute(\Attribute::TARGET_CLASS)] +class FieldType extends Plugin { + + /** + * Constructs a FieldType attribute. + * + * @param string $id + * The plugin ID. + * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label + * The human-readable name of the field type. + * @param \Drupal\Core\StringTranslation\TranslatableMarkup|array|null $description + * (optional) A short human-readable description for the field type. + * @param string $category + * (optional) The category under which the field type should be listed in + * the UI. + * @param int $weight + * (optional) The weight of the field type. + * @param string|null $default_widget + * (optional) The plugin_id of the default widget for this field type. + * This widget must be available whenever the field type is available (i.e. + * provided by the field type module, or by a module the field type module + * depends on). + * @param string|null $default_formatter + * (optional) The plugin_id of the default formatter for this field type. + * This formatter must be available whenever the field type is available + * (i.e. provided by the field type module, or by a module the field type + * module depends on). + * @param bool $no_ui + * (optional) A boolean stating that fields of this type cannot be created + * through the UI. + * @param string|null $list_class + * (optional) The typed data class used for wrapping multiple data items of + * the type. Must implement the \Drupal\Core\TypedData\ListInterface. + * @param int|null $cardinality + * (optional) An integer defining a fixed cardinality for this field type. + * If this value is not set, cardinality can be configured in the field UI. + * @param array $constraints + * (optional) An array of validation constraints for this type. + * @param array $config_dependencies + * (optional) An array of configuration dependencies. + * @param array $column_groups + * (optional) An array of column groups for the field type. + * @param array $serialized_property_names + * (optional) An array of property names that should be serialized. + * @param string|null $deriver + * (optional) The deriver class for the data type. + * @param string|null $module + * The name of the module providing the field type plugin. + */ + public function __construct( + public readonly string $id, + public readonly TranslatableMarkup $label, + public readonly TranslatableMarkup|array|null $description = NULL, + public readonly string $category = '', + public readonly int $weight = 0, + public readonly ?string $default_widget = NULL, + public readonly ?string $default_formatter = NULL, + public readonly bool $no_ui = FALSE, + public readonly ?string $list_class = NULL, + public readonly ?int $cardinality = NULL, + public readonly array $constraints = [], + public readonly array $config_dependencies = [], + public readonly array $column_groups = [], + public readonly array $serialized_property_names = [], + public readonly ?string $deriver = NULL, + public readonly ?string $module = NULL, + ) { + } + +} diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php index 228f3bb8d2c0d7a21a84436ffe45df230e58389a..5bc4a206de1662e7b8ba44a6ef681591c4d2f6fd 100644 --- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php @@ -6,6 +6,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Plugin\CategorizingPluginManagerTrait; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -45,7 +46,15 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePl * The field type category plugin manager. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, TypedDataManagerInterface $typed_data_manager, protected ?FieldTypeCategoryManagerInterface $fieldTypeCategoryManager = NULL) { - parent::__construct('Plugin/Field/FieldType', $namespaces, $module_handler, 'Drupal\Core\Field\FieldItemInterface', 'Drupal\Core\Field\Annotation\FieldType'); + parent::__construct( + 'Plugin/Field/FieldType', + $namespaces, + $module_handler, + FieldItemInterface::class, + FieldType::class, + 'Drupal\Core\Field\Annotation\FieldType', + ); + $this->alterInfo('field_info'); $this->setCacheBackend($cache_backend, 'field_types_plugins'); $this->typedDataManager = $typed_data_manager; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php index b7b03cfd7d4ef8ec3fd8f0cb8957450e345900ab..e52da2578574cb527f41b2fb69036896a08c4baa 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php @@ -2,26 +2,26 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; -use Drupal\Core\TypedData\OptionsProviderInterface; use Drupal\Core\TypedData\DataDefinition; +use Drupal\Core\TypedData\OptionsProviderInterface; /** * Defines the 'boolean' entity field type. - * - * @FieldType( - * id = "boolean", - * label = @Translation("Boolean"), - * description = @Translation("Field to store a true or false value."), - * default_widget = "boolean_checkbox", - * default_formatter = "boolean", - * ) */ +#[FieldType( + id: "boolean", + label: new TranslatableMarkup("Boolean"), + description: new TranslatableMarkup("Field to store a true or false value."), + default_widget: "boolean_checkbox", + default_formatter: "boolean", +)] class BooleanItem extends FieldItemBase implements OptionsProviderInterface { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php index 9e737758ab3ab17c952efd6e1328a23dc491dc7b..7116809acdb4eb985178dfa94b227066927570a7 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php @@ -2,24 +2,27 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\ChangedFieldItemList; +use Drupal\Core\StringTranslation\TranslatableMarkup; + /** * Defines the 'changed' entity field type. * * Based on a field of this type, entity types can easily implement the * EntityChangedInterface. * - * @FieldType( - * id = "changed", - * label = @Translation("Last changed"), - * description = @Translation("An entity field containing a UNIX timestamp of when the entity has been last updated."), - * no_ui = TRUE, - * default_widget = "datetime_timestamp", - * default_formatter = "timestamp", - * list_class = "\Drupal\Core\Field\ChangedFieldItemList" - * ) - * * @see \Drupal\Core\Entity\EntityChangedInterface */ +#[FieldType( + id: "changed", + label: new TranslatableMarkup("Last changed"), + description: new TranslatableMarkup("An entity field containing a UNIX timestamp of when the entity has been last updated."), + default_widget: "datetime_timestamp", + default_formatter: "timestamp", + no_ui: TRUE, + list_class: ChangedFieldItemList::class, +)] class ChangedItem extends CreatedItem { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php index 78a66a7f849a819de7515428819d6c3e80174217..94faaf4464350c97945aee789a1d72c5eddcc546 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php @@ -2,18 +2,20 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\StringTranslation\TranslatableMarkup; + /** * Defines the 'created' entity field type. - * - * @FieldType( - * id = "created", - * label = @Translation("Created"), - * description = @Translation("An entity field containing a UNIX timestamp of when the entity has been created."), - * no_ui = TRUE, - * default_widget = "datetime_timestamp", - * default_formatter = "timestamp" - * ) */ +#[FieldType( + id: "created", + label: new TranslatableMarkup("Created"), + description: new TranslatableMarkup("An entity field containing a UNIX timestamp of when the entity has been created."), + default_widget: "datetime_timestamp", + default_formatter: "timestamp", + no_ui: TRUE, +)] class CreatedItem extends TimestampItem { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php index 561a2d9151a6b7a18146f95b7c39abb81775f7c6..6997c1bb8fa5bef93b15aed05c4e4f55ac3f047e 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php @@ -2,29 +2,29 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TypedData\DataDefinition; /** * Defines the 'decimal' field type. - * - * @FieldType( - * id = "decimal", - * label = @Translation("Number (decimal)"), - * description = { - * @Translation("Ideal for exact counts and measures (prices, temperatures, distances, volumes, etc.)"), - * @Translation("Stores a number in the database in a fixed decimal format"), - * @Translation("For example, 12.34 km or € when used for further detailed calculations (such as summing many of these)"), - * }, - * category = "number", - * weight = -30, - * default_widget = "number", - * default_formatter = "number_decimal" - * ) */ +#[FieldType( + id: "decimal", + label: new TranslatableMarkup("Number (decimal)"), + description: [ + new TranslatableMarkup("Ideal for exact counts and measures (prices, temperatures, distances, volumes, etc.)"), + new TranslatableMarkup("Stores a number in the database in a fixed decimal format"), + new TranslatableMarkup("For example, 12.34 km or € when used for further detailed calculations (such as summing many of these)"), + ], + category: "number", + weight: -30, + default_widget: "number", + default_formatter: "number_decimal" +)] class DecimalItem extends NumericItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php index 639d8d5e2864071a0ea7964a80bcb027d345d324..33c8849f3f95e8a85de68db8173e318919b027c3 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php @@ -3,6 +3,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Component\Utility\Random; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldItemBase; @@ -12,15 +13,14 @@ /** * Defines the 'email' field type. - * - * @FieldType( - * id = "email", - * label = @Translation("Email"), - * description = @Translation("Field to store an email address."), - * default_widget = "email_default", - * default_formatter = "basic_string" - * ) */ +#[FieldType( + id: "email", + label: new TranslatableMarkup("Email"), + description: new TranslatableMarkup("Field to store an email address."), + default_widget: "email_default", + default_formatter: "basic_string" +)] class EmailItem extends FieldItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 782ecba82e9e2ac97434eb3d09108f0be9f07aab..b2e621fd12d018243dc64c77cead1b2646d2c434 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -10,6 +10,8 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\TypedData\EntityDataDefinition; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\EntityReferenceFieldItemList; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldException; use Drupal\Core\Field\FieldStorageDefinitionInterface; @@ -29,17 +31,16 @@ * * Supported settings (below the definition's 'settings' key) are: * - target_type: The entity type to reference. Required. - * - * @FieldType( - * id = "entity_reference", - * label = @Translation("Entity reference"), - * description = @Translation("An entity field containing an entity reference."), - * category = "reference", - * default_widget = "entity_reference_autocomplete", - * default_formatter = "entity_reference_label", - * list_class = "\Drupal\Core\Field\EntityReferenceFieldItemList", - * ) */ +#[FieldType( + id: "entity_reference", + label: new TranslatableMarkup("Entity reference"), + description: new TranslatableMarkup("An entity field containing an entity reference."), + category: "reference", + default_widget: "entity_reference_autocomplete", + default_formatter: "entity_reference_label", + list_class: EntityReferenceFieldItemList::class, +)] class EntityReferenceItem extends EntityReferenceItemBase implements OptionsProviderInterface, PreconfiguredFieldUiOptionsInterface { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php index 2e120c0ad1d455ec08ccd840b8b408a6f4f13618..8ae9fe36834d6ad83a5a400337f1d23ea7797c72 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php @@ -2,28 +2,29 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; /** * Defines the 'float' field type. - * - * @FieldType( - * id = "float", - * label = @Translation("Number (float)"), - * description = { - * @Translation("In most instances, it is best to use Number (decimal) instead, as decimal numbers stored as floats may contain errors in precision"), - * @Translation("This type of field offers faster processing and more compact storage, but the differences are typically negligible on modern sites"), - * @Translation("For example, 123.4 km when used in imprecise contexts such as a walking trail distance"), - * }, - * category = "number", - * weight = -10, - * default_widget = "number", - * default_formatter = "number_decimal" - * ) */ +#[FieldType( + id: "float", + label: new TranslatableMarkup("Number (float)"), + description: [ + new TranslatableMarkup("In most instances, it is best to use Number (decimal) instead, as decimal numbers stored as floats may contain errors in precision"), + new TranslatableMarkup("This type of field offers faster processing and more compact storage, but the differences are typically negligible on modern sites"), + new TranslatableMarkup("For example, 123.4 km when used in imprecise contexts such as a walking trail distance"), + ], + category: "number", + weight: -10, + default_widget: "number", + default_formatter: "number_decimal" +)] class FloatItem extends NumericItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php index dcb4275d9d8e68dfbe8275546df6698adf5302c0..a3125b2ea531c163d206fcf82d1412b4d64e1389 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php @@ -2,27 +2,27 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TypedData\DataDefinition; /** * Defines the 'integer' field type. - * - * @FieldType( - * id = "integer", - * label = @Translation("Number (integer)"), - * description = { - * @Translation("Number without decimals"), - * @Translation("For example, 123"), - * }, - * category = "number", - * weight = -50, - * default_widget = "number", - * default_formatter = "number_integer" - * ) */ +#[FieldType( + id: "integer", + label: new TranslatableMarkup("Number (integer)"), + description: [ + new TranslatableMarkup("Number without decimals"), + new TranslatableMarkup("For example, 123"), + ], + category: "number", + weight: -50, + default_widget: "number", + default_formatter: "number_integer" +)] class IntegerItem extends NumericItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index 5ca1449f526316d5dbac40cd8f58fe1f55c0b3d6..aec1052d517425588d4ee44672f6a8cd7bb0acf4 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -2,34 +2,35 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataReferenceDefinition; use Drupal\Core\TypedData\OptionsProviderInterface; /** * Defines the 'language' entity field item. - * - * @FieldType( - * id = "language", - * label = @Translation("Language"), - * description = @Translation("An entity field referencing a language."), - * default_widget = "language_select", - * default_formatter = "language", - * no_ui = TRUE, - * constraints = { - * "ComplexData" = { - * "value" = { - * "Length" = {"max" = 12} - * } - * } - * } - * ) */ +#[FieldType( + id: "language", + label: new TranslatableMarkup("Language"), + description: new TranslatableMarkup("An entity field referencing a language."), + default_widget: "language_select", + default_formatter: "language", + no_ui: TRUE, + constraints: [ + "ComplexData" => [ + "value" => [ + "Length" => ["max" => 12], + ], + ], + ] +)] class LanguageItem extends FieldItemBase implements OptionsProviderInterface { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php index be4887aaa70fea342f345aae587df2d76b9ced0f..9f7eaef8d82a2e0e142311c9519caded79daf116 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php @@ -2,20 +2,22 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Field\MapFieldItemList; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'map' entity field type. - * - * @FieldType( - * id = "map", - * label = @Translation("Map"), - * description = @Translation("An entity field for storing a serialized array of values."), - * no_ui = TRUE, - * list_class = "\Drupal\Core\Field\MapFieldItemList", - * ) */ +#[FieldType( + id: "map", + label: new TranslatableMarkup("Map"), + description: new TranslatableMarkup("An entity field for storing a serialized array of values."), + no_ui: TRUE, + list_class: MapFieldItemList::class, +)] class MapItem extends FieldItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php index 1e5eca9e9405157158c87dcb31fce9618303082d..a7c8460a7c48416bca63aa31bb39efdfcd65214e 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php @@ -3,20 +3,20 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Core\Entity\EntityMalformedException; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; /** * Defines the 'password' entity field type. - * - * @FieldType( - * id = "password", - * label = @Translation("Password"), - * description = @Translation("An entity field containing a password value."), - * no_ui = TRUE, - * ) */ +#[FieldType( + id: "password", + label: new TranslatableMarkup("Password"), + description: new TranslatableMarkup("An entity field containing a password value."), + no_ui: TRUE, +)] class PasswordItem extends StringItem { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php index 0df368c5a7525bac0930d0d7a0b91339686ce548..75163e6f2c8aa233f564c261f304a53509b89a7d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php @@ -3,27 +3,28 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Component\Utility\Random; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'string' entity field type. - * - * @FieldType( - * id = "string", - * label = @Translation("Text (plain)"), - * description = { - * @Translation("Ideal for titles and names"), - * @Translation("Efficient storage for short text"), - * @Translation("Requires specifying a maximum length"), - * @Translation("Good for fields with known or predictable length"), - * }, - * category = "plain_text", - * default_widget = "string_textfield", - * default_formatter = "string" - * ) */ +#[FieldType( + id: "string", + label: new TranslatableMarkup("Text (plain)"), + description: [ + new TranslatableMarkup("Ideal for titles and names"), + new TranslatableMarkup("Efficient storage for short text"), + new TranslatableMarkup("Requires specifying a maximum length"), + new TranslatableMarkup("Good for fields with known or predictable length"), + ], + category: "plain_text", + default_widget: "string_textfield", + default_formatter: "string" +)] class StringItem extends StringItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php index b98f76fbfb8a8f71f3b35506997b72fdebdbd6a0..aafdeb2c8e2ab20899d4936901f9fccb32bce3c3 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php @@ -3,25 +3,26 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Component\Utility\Random; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'string_long' field type. - * - * @FieldType( - * id = "string_long", - * label = @Translation("Text (plain, long)"), - * description = { - * @Translation("Ideal for longer texts, like body or description"), - * @Translation("Supports long text without specifying a maximum length"), - * @Translation("May use more storage and be slower for searching and sorting"), - * }, - * category = "plain_text", - * default_widget = "string_textarea", - * default_formatter = "basic_string", - * ) */ +#[FieldType( + id: "string_long", + label: new TranslatableMarkup("Text (plain, long)"), + description: [ + new TranslatableMarkup("Ideal for longer texts, like body or description"), + new TranslatableMarkup("Supports long text without specifying a maximum length"), + new TranslatableMarkup("May use more storage and be slower for searching and sorting"), + ], + category: "plain_text", + default_widget: "string_textarea", + default_formatter: "basic_string", +)] class StringLongItem extends StringItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php index 44ae5a7f188065aaffa950c9e7d14d9f511d2b73..79d7353894bd3f12f45c5edfc1510d03ed0f0fe8 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php @@ -2,37 +2,38 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; /** * Defines the 'timestamp' entity field type. - * - * @FieldType( - * id = "timestamp", - * label = @Translation("Timestamp"), - * description = { - * @Translation("Ideal for using date and time calculations or comparisons"), - * @Translation("Date and time stored in the form of seconds since January 1, 1970 (UTC)"), - * @Translation("Compact and efficient for storage, sorting and calculations"), - * }, - * category = "date_time", - * default_widget = "datetime_timestamp", - * default_formatter = "timestamp", - * constraints = { - * "ComplexData" = { - * "value" = { - * "Range" = { - * "min" = "-2147483648", - * "max" = "2147483648", - * } - * } - * } - * } - * ) */ +#[FieldType( + id: "timestamp", + label: new TranslatableMarkup("Timestamp"), + description: [ + new TranslatableMarkup("Ideal for using date and time calculations or comparisons"), + new TranslatableMarkup("Date and time stored in the form of seconds since January 1, 1970 (UTC)"), + new TranslatableMarkup("Compact and efficient for storage, sorting and calculations"), + ], + category: "date_time", + default_widget: "datetime_timestamp", + default_formatter: "timestamp", + constraints: [ + "ComplexData" => [ + "value" => [ + "Range" => [ + "min" => "-2147483648", + "max" => "2147483648", + ], + ], + ], + ] +)] class TimestampItem extends FieldItemBase { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php index 6194244041e0c3174b2616d7bb8611e2d6be51f4..bc3ede8ba95519f03770a295065601c27353cea8 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php @@ -3,8 +3,10 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Component\Utility\Random; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; /** @@ -13,16 +15,15 @@ * URIs are not length limited by RFC 2616, but we need to provide a sensible * default. There is a de-facto limit of 2000 characters in browsers and other * implementors, so we go with 2048. - * - * @FieldType( - * id = "uri", - * label = @Translation("URI"), - * description = @Translation("An entity field containing a URI."), - * no_ui = TRUE, - * default_formatter = "uri_link", - * default_widget = "uri", - * ) */ +#[FieldType( + id: "uri", + label: new TranslatableMarkup("URI"), + description: new TranslatableMarkup("An entity field containing a URI."), + default_widget: "uri", + default_formatter: "uri_link", + no_ui: TRUE, +)] class UriItem extends StringItem { /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php index a5f94010880b9813596d4458149823fc45c5c899..c52ba1a39e3e8b9ded2207bd28d91772a1922094 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php @@ -2,22 +2,23 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'uuid' entity field type. * * The field uses a newly generated UUID as default value. - * - * @FieldType( - * id = "uuid", - * label = @Translation("UUID"), - * description = @Translation("An entity field containing a UUID."), - * no_ui = TRUE, - * default_formatter = "string" - * ) */ +#[FieldType( + id: "uuid", + label: new TranslatableMarkup("UUID"), + description: new TranslatableMarkup("An entity field containing a UUID."), + default_formatter: "string", + no_ui: TRUE +)] class UuidItem extends StringItem { /** diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index 8833651a3dca526a05a626a318e59c4e5651db03..1f16bf7386f5c48ec888e9c6331c2d15f364f3b6 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -2,31 +2,32 @@ namespace Drupal\comment\Plugin\Field\FieldType; +use Drupal\comment\CommentFieldItemList; use Drupal\comment\CommentInterface; use Drupal\comment\CommentManagerInterface; use Drupal\comment\Entity\CommentType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Session\AnonymousUserSession; -use Drupal\Core\Url; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TypedData\DataDefinition; +use Drupal\Core\Url; /** * Plugin implementation of the 'comment' field type. - * - * @FieldType( - * id = "comment", - * label = @Translation("Comments"), - * description = @Translation("This field manages configuration and presentation of comments on an entity."), - * list_class = "\Drupal\comment\CommentFieldItemList", - * default_widget = "comment_default", - * default_formatter = "comment_default", - * cardinality = 1, - * ) */ +#[FieldType( + id: "comment", + label: new TranslatableMarkup("Comments"), + description: new TranslatableMarkup("This field manages configuration and presentation of comments on an entity."), + default_widget: "comment_default", + default_formatter: "comment_default", + list_class: CommentFieldItemList::class, + cardinality: 1, +)] class CommentItem extends FieldItemBase implements CommentItemInterface { /** diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php index ee104a410edaf157f0d61be849591879fe893abb..68742eba0583fce13c50d052bbbc8fa4612177ad 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php @@ -2,31 +2,31 @@ namespace Drupal\datetime\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TypedData\DataDefinition; /** * Plugin implementation of the 'datetime' field type. - * - * @FieldType( - * id = "datetime", - * label = @Translation("Date"), - * description = { - * @Translation("Ideal when date and time needs to be input by users, like event dates and times"), - * @Translation("Date or date and time stored in a readable string format"), - * @Translation("Easy to read and understand for humans"), - * }, - * category = "date_time", - * default_widget = "datetime_default", - * default_formatter = "datetime_default", - * list_class = "\Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList", - * constraints = {"DateTimeFormat" = {}} - * ) */ +#[FieldType( + id: "datetime", + label: new TranslatableMarkup("Date"), + description: [ + new TranslatableMarkup("Ideal when date and time needs to be input by users, like event dates and times"), + new TranslatableMarkup("Date or date and time stored in a readable string format"), + new TranslatableMarkup("Easy to read and understand for humans"), + ], + category: "date_time", + default_widget: "datetime_default", + default_formatter: "datetime_default", + list_class: DateTimeFieldItemList::class, + constraints: ["DateTimeFormat" => []] +)] class DateTimeItem extends FieldItemBase implements DateTimeItemInterface { /** diff --git a/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeItem.php b/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeItem.php index 3020a98de6faccf903cc289174a12799cd72c572..85680e6914635cac14e83283bb7fac2071dcdf72 100644 --- a/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeItem.php +++ b/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeItem.php @@ -2,9 +2,11 @@ namespace Drupal\datetime_range\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; use Drupal\datetime\DateTimeComputed; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; @@ -12,21 +14,20 @@ /** * Plugin implementation of the 'daterange' field type. - * - * @FieldType( - * id = "daterange", - * label = @Translation("Date range"), - * category = "date_time", - * description = { - * @Translation("Ideal for storing durations that consist of start and end dates (and times)"), - * @Translation("Choose between setting both date and time, or date only, for each duration"), - * @Translation("The system automatically validates that the end date (and time) is later than the start, and both fields are completed"), - * }, - * default_widget = "daterange_default", - * default_formatter = "daterange_default", - * list_class = "\Drupal\datetime_range\Plugin\Field\FieldType\DateRangeFieldItemList" - * ) */ +#[FieldType( + id: "daterange", + label: new TranslatableMarkup("Date range"), + description: [ + new TranslatableMarkup("Ideal for storing durations that consist of start and end dates (and times)"), + new TranslatableMarkup("Choose between setting both date and time, or date only, for each duration"), + new TranslatableMarkup("The system automatically validates that the end date (and time) is later than the start, and both fields are completed"), + ], + category: "date_time", + default_widget: "daterange_default", + default_formatter: "daterange_default", + list_class: DateRangeFieldItemList::class, +)] class DateRangeItem extends DateTimeItem { /** diff --git a/core/modules/editor/tests/modules/editor_test/src/Plugin/Field/FieldType/EditorTestTextLongItem.php b/core/modules/editor/tests/modules/editor_test/src/Plugin/Field/FieldType/EditorTestTextLongItem.php index 5c0c964a6bcb642c892b68c03f9ea1338d84e6cb..5b82a66f6d08dcbc1572b483ae26b203905362f0 100644 --- a/core/modules/editor/tests/modules/editor_test/src/Plugin/Field/FieldType/EditorTestTextLongItem.php +++ b/core/modules/editor/tests/modules/editor_test/src/Plugin/Field/FieldType/EditorTestTextLongItem.php @@ -2,19 +2,20 @@ namespace Drupal\editor_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\text\Plugin\Field\FieldType\TextLongItem; /** * Plugin implementation of the 'editor_test_text_long' field type. - * - * @FieldType( - * id = "editor_test_text_long", - * label = @Translation("Filter test text (formatted, long)"), - * description = @Translation("This field stores a long text with a text format."), - * default_widget = "text_textarea", - * default_formatter = "text_default" - * ) */ +#[FieldType( + id: "editor_test_text_long", + label: new TranslatableMarkup("Filter test text (formatted, long)"), + description: new TranslatableMarkup("This field stores a long text with a text format."), + default_widget: "text_textarea", + default_formatter: "text_default" +)] class EditorTestTextLongItem extends TextLongItem { } diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 7656b41d58b76c3175eb2c92ec6322740a50bc38..f8d72a26dbac7e45ddbc0a9945b93c338c4c35b9 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -20,8 +20,8 @@ * and so on. The data type(s) accepted by a field are defined in the class * implementing \Drupal\Core\Field\FieldItemInterface::schema() method. * - * Field types are plugins annotated with class - * \Drupal\Core\Field\Annotation\FieldType, and implement plugin interface + * Field types are plugins with \Drupal\Core\Field\Attribute\FieldType + * attributes and implement plugin interface * \Drupal\Core\Field\FieldItemInterface. Field Type plugins are managed by the * \Drupal\Core\Field\FieldTypePluginManager class. Field type classes usually * extend base class \Drupal\Core\Field\FieldItemBase. Field-type plugins need diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php index 3f90cc33538969eda76ba0ec9e27bdfe7402f61d..6a5fb1e1783227bbc40be5a626ffb50deec57429 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php @@ -2,18 +2,20 @@ namespace Drupal\field_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\StringTranslation\TranslatableMarkup; + /** * Defines the 'hidden_test' entity field item. - * - * @FieldType( - * id = "hidden_test_field", - * label = @Translation("Hidden from UI test field"), - * description = @Translation("Dummy hidden field type used for tests."), - * no_ui = TRUE, - * default_widget = "test_field_widget", - * default_formatter = "field_test_default" - * ) */ +#[FieldType( + id: "hidden_test_field", + label: new TranslatableMarkup("Hidden from UI test field"), + description: new TranslatableMarkup("Dummy hidden field type used for tests."), + default_widget: "test_field_widget", + default_formatter: "field_test_default", + no_ui: TRUE +)] class HiddenTestItem extends TestItem { } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php index 2f64264b54dd3c46b2c335c08715ff31902f06a1..6605aabdb50a6e5ba4d6ebeb4e0ed2d54d98191a 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php @@ -2,22 +2,22 @@ namespace Drupal\field_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; /** * Defines the 'test_field' entity field item. - * - * @FieldType( - * id = "test_field", - * label = @Translation("Test field"), - * default_widget = "test_field_widget", - * default_formatter = "field_test_default" - * ) */ +#[FieldType( + id: "test_field", + label: new TranslatableMarkup("Test field"), + default_widget: "test_field_widget", + default_formatter: "field_test_default" +)] class TestItem extends FieldItemBase { /** diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithDependencies.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithDependencies.php index 217d1abcefa3b2d384e3b69e86863ad281dea0c0..3e1631f04a9242c31fd105bb41c0c84f38055020 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithDependencies.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithDependencies.php @@ -2,24 +2,23 @@ namespace Drupal\field_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'test_field_with_dependencies' entity field item. - * - * @FieldType( - * id = "test_field_with_dependencies", - * label = @Translation("Test field with dependencies"), - * description = @Translation("Dummy field type used for tests."), - * default_widget = "test_field_widget", - * default_formatter = "field_test_default", - * config_dependencies = { - * "module" = { - * "system" - * } - * } - * ) */ +#[FieldType( + id: "test_field_with_dependencies", + label: new TranslatableMarkup("Test field with dependencies"), + description: new TranslatableMarkup("Dummy field type used for tests."), + default_widget: "test_field_widget", + default_formatter: "field_test_default", + config_dependencies: [ + "module" => ["system"], + ] +)] class TestItemWithDependencies extends TestItem { /** diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithMultipleDescriptions.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithMultipleDescriptions.php index d193ebf2f8119bb7d2096c46633b6136b0be7d09..0148e127865cb05a32ef84711d4554ab213cc191 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithMultipleDescriptions.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithMultipleDescriptions.php @@ -4,20 +4,22 @@ namespace Drupal\field_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\StringTranslation\TranslatableMarkup; + /** * Defines the 'test_field_with_multiple_descriptions' entity field item. - * - * @FieldType( - * id = "test_field_with_multiple_descriptions", - * label = @Translation("Test field (multiple descriptions"), - * description = { - * @Translation("This multiple line description needs to use an array"), - * @Translation("This second line contains important information"), - * }, - * category = "field_test_descriptions", - * default_widget = "test_field_widget", - * default_formatter = "field_test_default" - * ) */ +#[FieldType( + id: "test_field_with_multiple_descriptions", + label: new TranslatableMarkup("Test field (multiple descriptions"), + description: [ + new TranslatableMarkup("This multiple line description needs to use an array"), + new TranslatableMarkup("This second line contains important information"), + ], + category: "field_test_descriptions", + default_widget: "test_field_widget", + default_formatter: "field_test_default" +)] class TestItemWithMultipleDescriptions extends TestItem { } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php index a35642ac134d8936a9087c6fed8167f51205b27e..c9d76509feb023fdee85c8a7482a21aec1686b99 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php @@ -2,21 +2,21 @@ namespace Drupal\field_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'test_field_with_preconfigured_options' entity field item. - * - * @FieldType( - * id = "test_field_with_preconfigured_options", - * label = @Translation("Test field with preconfigured options"), - * description = @Translation("Dummy field type used for tests."), - * default_widget = "test_field_widget", - * default_formatter = "field_test_default" - * ) */ +#[FieldType( + id: "test_field_with_preconfigured_options", + label: new TranslatableMarkup("Test field with preconfigured options"), + description: new TranslatableMarkup("Dummy field type used for tests."), + default_widget: "test_field_widget", + default_formatter: "field_test_default" +)] class TestItemWithPreconfiguredOptions extends TestItem implements PreconfiguredFieldUiOptionsInterface { /** diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithSingleDescription.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithSingleDescription.php index e14dd039bb5c79da369e5ef0fd1a9cc8e22bd6e5..6c323281833f46349412340bbba48fe64c7d9597 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithSingleDescription.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithSingleDescription.php @@ -4,17 +4,19 @@ namespace Drupal\field_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\StringTranslation\TranslatableMarkup; + /** * Defines the 'test_field_with_single_description' entity field item. - * - * @FieldType( - * id = "test_field_with_single_description", - * label = @Translation("Test field (single description"), - * description = @Translation("This one-line field description is important for testing"), - * category = "field_test_descriptions", - * default_widget = "test_field_widget", - * default_formatter = "field_test_default" - * ) */ +#[FieldType( + id: "test_field_with_single_description", + label: new TranslatableMarkup("Test field (single description"), + description: new TranslatableMarkup("This one-line field description is important for testing"), + category: "field_test_descriptions", + default_widget: "test_field_widget", + default_formatter: "field_test_default" +)] class TestItemWithSingleDescription extends TestItem { } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php index d5647c2f6a849027cb2ceefa1a8978118d073024..160b6bfc30f52ef37dc8659a2a58027009bde12a 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestObjectItem.php @@ -2,21 +2,22 @@ namespace Drupal\field_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; /** * Defines the 'test_object_field' entity field item. - * - * @FieldType( - * id = "test_object_field", - * label = @Translation("Test object field"), - * description = @Translation("Test field type that has an object to test serialization"), - * default_widget = "test_object_field_widget", - * default_formatter = "object_field_test_default" - * ) */ +#[FieldType( + id: "test_object_field", + label: new TranslatableMarkup("Test object field"), + description: new TranslatableMarkup("Test field type that has an object to test serialization"), + default_widget: "test_object_field_widget", + default_formatter: "object_field_test_default" +)] class TestObjectItem extends FieldItemBase { /** diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php index 60bc20af7fe7491788b61dc60bfa631c011c80ae..799d31af8ecbfda958b3a4fc69e433eaaea1d169 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -6,6 +6,7 @@ use Drupal\Component\Utility\Bytes; use Drupal\Component\Utility\Environment; use Drupal\Component\Utility\Random; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; @@ -20,21 +21,20 @@ /** * Plugin implementation of the 'file' field type. - * - * @FieldType( - * id = "file", - * label = @Translation("File"), - * description = { - * @Translation("For uploading files"), - * @Translation("Can be configured with options such as allowed file extensions and maximum upload size"), - * }, - * category = "file_upload", - * default_widget = "file_generic", - * default_formatter = "file_default", - * list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList", - * constraints = {"ReferenceAccess" = {}, "FileValidation" = {}} - * ) */ +#[FieldType( + id: "file", + label: new TranslatableMarkup("File"), + description: [ + new TranslatableMarkup("For uploading files"), + new TranslatableMarkup("Can be configured with options such as allowed file extensions and maximum upload size"), + ], + category: "file_upload", + default_widget: "file_generic", + default_formatter: "file_default", + list_class: FileFieldItemList::class, + constraints: ["ReferenceAccess" => [], "FileValidation" => []] +)] class FileItem extends EntityReferenceItem { use FileValidatorSettingsTrait; diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php index 33bc15ef03f120059cb006e7bccad661f8cad681..0e116b597a90082df00d87020e1f8b0be31e74cb 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php @@ -2,23 +2,24 @@ namespace Drupal\file\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\UriItem; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; use Drupal\file\ComputedFileUrl; /** * File-specific plugin implementation of a URI item to provide a full URL. - * - * @FieldType( - * id = "file_uri", - * label = @Translation("File URI"), - * description = @Translation("An entity field containing a file URI, and a computed root-relative file URL."), - * no_ui = TRUE, - * default_formatter = "file_uri", - * default_widget = "uri", - * ) */ +#[FieldType( + id: "file_uri", + label: new TranslatableMarkup("File URI"), + description: new TranslatableMarkup("An entity field containing a file URI, and a computed root-relative file URL."), + default_widget: "uri", + default_formatter: "file_uri", + no_ui: TRUE, +)] class FileUriItem extends UriItem { /** diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php index d98f6c1534e43f2af37e39c15e67d3386e3ac2bb..29fa146d487431b8ca07785c3ddc5d7eda143a1f 100644 --- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php @@ -4,6 +4,7 @@ use Drupal\Component\Utility\Random; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\File\Exception\FileException; @@ -14,43 +15,47 @@ use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; use Drupal\file\Entity\File; +use Drupal\file\Plugin\Field\FieldType\FileFieldItemList; use Drupal\file\Plugin\Field\FieldType\FileItem; /** * Plugin implementation of the 'image' field type. - * - * @FieldType( - * id = "image", - * label = @Translation("Image"), - * description = { - * @Translation("For uploading images"), - * @Translation("Allows a user to upload an image with configurable extensions, image dimensions, upload size"), - * @Translation("Can be configured with options such as allowed file extensions, maximum upload size and image dimensions minimums/maximums"), - * }, - * category = "file_upload", - * default_widget = "image_image", - * default_formatter = "image", - * column_groups = { - * "file" = { - * "label" = @Translation("File"), - * "columns" = { - * "target_id", "width", "height" - * }, - * "require_all_groups_for_translation" = TRUE - * }, - * "alt" = { - * "label" = @Translation("Alt"), - * "translatable" = TRUE - * }, - * "title" = { - * "label" = @Translation("Title"), - * "translatable" = TRUE - * }, - * }, - * list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList", - * constraints = {"ReferenceAccess" = {}, "FileValidation" = {}} - * ) */ +#[FieldType( + id: "image", + label: new TranslatableMarkup("Image"), + description: [ + new TranslatableMarkup("For uploading images"), + new TranslatableMarkup("Allows a user to upload an image with configurable extensions, image dimensions, upload size"), + new TranslatableMarkup( + "Can be configured with options such as allowed file extensions, maximum upload size and image dimensions minimums/maximums" + ), + ], + category: "file_upload", + default_widget: "image_image", + default_formatter: "image", + list_class: FileFieldItemList::class, + constraints: ["ReferenceAccess" => [], "FileValidation" => []], + column_groups: [ + "file" => [ + "label" => new TranslatableMarkup("File"), + "columns" => [ + "target_id", + "width", + "height", + ], + "require_all_groups_for_translation" => TRUE, + ], + "alt" => [ + "label" => new TranslatableMarkup("Alt"), + "translatable" => TRUE, + ], + "title" => [ + "label" => new TranslatableMarkup("Title"), + "translatable" => TRUE, + ], + ] +)] class ImageItem extends FileItem { use LoggerChannelTrait; diff --git a/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php b/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php index 587661234564c827ca69b0d02a9e05b54ed03bab..bf2453055c25beda4e82249589fa61477a2900c0 100644 --- a/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php +++ b/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php @@ -2,22 +2,22 @@ namespace Drupal\image_module_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TypedData\DataDefinition; /** * Defines a dummy field containing an AJAX handler. - * - * @FieldType( - * id = "image_module_test_dummy_ajax", - * label = @Translation("Dummy AJAX"), - * description = @Translation("A field containing an AJAX handler."), - * default_widget = "image_module_test_dummy_ajax_widget", - * default_formatter = "image_module_test_dummy_ajax_formatter" - * ) */ +#[FieldType( + id: "image_module_test_dummy_ajax", + label: new TranslatableMarkup("Dummy AJAX"), + description: new TranslatableMarkup("A field containing an AJAX handler."), + default_widget: "image_module_test_dummy_ajax_widget", + default_formatter: "image_module_test_dummy_ajax_formatter" +)] class DummyAjaxItem extends FieldItemBase { /** diff --git a/core/modules/layout_builder/src/Plugin/Field/FieldType/LayoutSectionItem.php b/core/modules/layout_builder/src/Plugin/Field/FieldType/LayoutSectionItem.php index a132c8234cb24f734fe14565a18df7d30fe699cf..6710171752c1c26dcf80816c3322892825f01825 100644 --- a/core/modules/layout_builder/src/Plugin/Field/FieldType/LayoutSectionItem.php +++ b/core/modules/layout_builder/src/Plugin/Field/FieldType/LayoutSectionItem.php @@ -2,11 +2,13 @@ namespace Drupal\layout_builder\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; +use Drupal\layout_builder\Field\LayoutSectionItemList; use Drupal\layout_builder\Section; /** @@ -15,17 +17,16 @@ * @internal * Plugin classes are internal. * - * @FieldType( - * id = "layout_section", - * label = @Translation("Layout Section"), - * description = @Translation("Layout Section"), - * list_class = "\Drupal\layout_builder\Field\LayoutSectionItemList", - * no_ui = TRUE, - * cardinality = \Drupal\Core\Field\FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED - * ) - * * @property \Drupal\layout_builder\Section $section */ +#[FieldType( + id: "layout_section", + label: new TranslatableMarkup("Layout Section"), + description: new TranslatableMarkup("Layout Section"), + no_ui: TRUE, + list_class: LayoutSectionItemList::class, + cardinality: FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED +)] class LayoutSectionItem extends FieldItemBase { /** diff --git a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php index b77acedf7ff27a3a7fc0b658d5621a63afa4a2dc..2849b0ac83e9711c61ca586072ea4b46c6346ce6 100644 --- a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php +++ b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php @@ -3,28 +3,33 @@ namespace Drupal\link\Plugin\Field\FieldType; use Drupal\Component\Utility\Random; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\MapDataDefinition; use Drupal\Core\Url; -use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\link\LinkItemInterface; /** * Plugin implementation of the 'link' field type. - * - * @FieldType( - * id = "link", - * label = @Translation("Link"), - * description = @Translation("Stores a URL string, optional varchar link text, and optional blob of attributes to assemble a link."), - * default_widget = "link_default", - * default_formatter = "link", - * constraints = {"LinkType" = {}, "LinkAccess" = {}, "LinkExternalProtocols" = {}, "LinkNotExistingInternal" = {}} - * ) */ +#[FieldType( + id: "link", + label: new TranslatableMarkup("Link"), + description: new TranslatableMarkup("Stores a URL string, optional varchar link text, and optional blob of attributes to assemble a link."), + default_widget: "link_default", + default_formatter: "link", + constraints: [ + "LinkType" => [], + "LinkAccess" => [], + "LinkExternalProtocols" => [], + "LinkNotExistingInternal" => [], + ] +)] class LinkItem extends FieldItemBase implements LinkItemInterface { /** diff --git a/core/modules/media_library/tests/modules/media_library_test/src/Plugin/Field/FieldType/EntityReferenceItemSubclass.php b/core/modules/media_library/tests/modules/media_library_test/src/Plugin/Field/FieldType/EntityReferenceItemSubclass.php index 9fd286d8af18a0faf76380bb201655041f1f5500..ff0c8f00640db784ebf88dc24b6e56bb48ef3234 100644 --- a/core/modules/media_library/tests/modules/media_library_test/src/Plugin/Field/FieldType/EntityReferenceItemSubclass.php +++ b/core/modules/media_library/tests/modules/media_library_test/src/Plugin/Field/FieldType/EntityReferenceItemSubclass.php @@ -2,20 +2,22 @@ namespace Drupal\media_library_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\EntityReferenceFieldItemList; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'entity_reference_subclass' field type. - * - * @FieldType( - * id = "entity_reference_subclass", - * label = @Translation("Entity reference subclass"), - * description = @Translation("An entity field containing an entity reference."), - * category = "reference", - * default_widget = "entity_reference_autocomplete", - * default_formatter = "entity_reference_label", - * list_class = "\Drupal\Core\Field\EntityReferenceFieldItemList", - * ) */ +#[FieldType( + id: "entity_reference_subclass", + label: new TranslatableMarkup("Entity reference subclass"), + description: new TranslatableMarkup("An entity field containing an entity reference."), + category: "reference", + default_widget: "entity_reference_autocomplete", + default_formatter: "entity_reference_label", + list_class: EntityReferenceFieldItemList::class, +)] class EntityReferenceItemSubclass extends EntityReferenceItem { } diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php index d2539dd66d185ae83c8f4da8511b68e7755d4750..ec213b08876c930c3fe46cc1981c5b7fcc58b3f5 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php @@ -2,6 +2,7 @@ namespace Drupal\options\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; @@ -11,20 +12,19 @@ /** * Plugin implementation of the 'list_float' field type. - * - * @FieldType( - * id = "list_float", - * label = @Translation("List (float)"), - * description = { - * @Translation("Values stored are floating-point numbers"), - * @Translation("For example, 'Fraction': 0 => 0, .25 => 1/4, .75 => 3/4, 1 => 1"), - * }, - * category = "selection_list", - * weight = -10, - * default_widget = "options_select", - * default_formatter = "list_default", - * ) */ +#[FieldType( + id: "list_float", + label: new TranslatableMarkup("List (float)"), + description: [ + new TranslatableMarkup("Values stored are floating-point numbers"), + new TranslatableMarkup("For example, 'Fraction': 0 => 0, .25 => 1/4, .75 => 3/4, 1 => 1"), + ], + category: "selection_list", + weight: -10, + default_widget: "options_select", + default_formatter: "list_default", +)] class ListFloatItem extends ListItemBase { /** diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php index 5132bb6c657403362e985ab36020d27296462d7f..f053b101039c2321d7ce6505981dbe88f6ae00a3 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php @@ -2,6 +2,7 @@ namespace Drupal\options\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; @@ -11,20 +12,19 @@ /** * Plugin implementation of the 'list_integer' field type. - * - * @FieldType( - * id = "list_integer", - * label = @Translation("List (integer)"), - * description = { - * @Translation("Values stored are numbers without decimals"), - * @Translation("For example, 'Lifetime in days': 1 => 1 day, 7 => 1 week, 31 => 1 month"), - * }, - * category = "selection_list", - * weight = -30, - * default_widget = "options_select", - * default_formatter = "list_default", - * ) */ +#[FieldType( + id: "list_integer", + label: new TranslatableMarkup("List (integer)"), + description: [ + new TranslatableMarkup("Values stored are numbers without decimals"), + new TranslatableMarkup("For example, 'Lifetime in days': 1 => 1 day, 7 => 1 week, 31 => 1 month"), + ], + category: "selection_list", + weight: -30, + default_widget: "options_select", + default_formatter: "list_default", +)] class ListIntegerItem extends ListItemBase { /** diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php index 22cd0d9ac678c71f7b904d3fe01c551656fe18e5..332a1768c23ee0d0e2fc9dac9b61aaa1f747d06e 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php @@ -2,6 +2,7 @@ namespace Drupal\options\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldFilteredMarkup; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; @@ -11,20 +12,19 @@ /** * Plugin implementation of the 'list_string' field type. - * - * @FieldType( - * id = "list_string", - * label = @Translation("List (text)"), - * description = { - * @Translation("Values stored are text values"), - * @Translation("For example, 'US States': IL => Illinois, IA => Iowa, IN => Indiana"), - * }, - * category = "selection_list", - * weight = -50, - * default_widget = "options_select", - * default_formatter = "list_default", - * ) */ +#[FieldType( + id: "list_string", + label: new TranslatableMarkup("List (text)"), + description: [ + new TranslatableMarkup("Values stored are text values"), + new TranslatableMarkup("For example, 'US States': IL => Illinois, IA => Iowa, IN => Indiana"), + ], + category: "selection_list", + weight: -50, + default_widget: "options_select", + default_formatter: "list_default", +)] class ListStringItem extends ListItemBase { /** diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php index ba57f2467c9574c6f073ed27099572e3e049fb79..6dd9111b225d1902996ccba046fe36b6296962f1 100644 --- a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php +++ b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php @@ -3,24 +3,25 @@ namespace Drupal\path\Plugin\Field\FieldType; use Drupal\Component\Utility\Random; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; /** * Defines the 'path' entity field type. - * - * @FieldType( - * id = "path", - * label = @Translation("Path"), - * description = @Translation("An entity field containing a path alias and related data."), - * no_ui = TRUE, - * default_widget = "path", - * list_class = "\Drupal\path\Plugin\Field\FieldType\PathFieldItemList", - * constraints = {"PathAlias" = {}}, - * ) */ +#[FieldType( + id: "path", + label: new TranslatableMarkup("Path"), + description: new TranslatableMarkup("An entity field containing a path alias and related data."), + default_widget: "path", + no_ui: TRUE, + list_class: PathFieldItemList::class, + constraints: ["PathAlias" => []], +)] class PathItem extends FieldItemBase { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/AutoIncrementingTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/AutoIncrementingTestItem.php index f0d6beacefa6fd136e1d7379f5e483a3e2fc7a29..de5a8f12f652326720852d4d4a10afe699370ee1 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/AutoIncrementingTestItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/AutoIncrementingTestItem.php @@ -2,18 +2,19 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'field_method_invocation_order_test' entity field type. - * - * @FieldType( - * id = "auto_incrementing_test", - * label = @Translation("Auto incrementing test field item"), - * description = @Translation("An entity field designed to test the field method invocation order."), - * no_ui = TRUE, - * ) */ +#[FieldType( + id: "auto_incrementing_test", + label: new TranslatableMarkup("Auto incrementing test field item"), + description: new TranslatableMarkup("An entity field designed to test the field method invocation order."), + no_ui: TRUE, +)] class AutoIncrementingTestItem extends IntegerItem { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php index 66b5b57f487e0d250be1a15a36c5adb4c46d7ef6..3a5495ab76e7152b12e16c3552f99f56451ee8f6 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php @@ -2,23 +2,25 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\ChangedFieldItemList; use Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'changed_test' entity field type. * * Wraps Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem. * - * @FieldType( - * id = "changed_test", - * label = @Translation("Last changed"), - * description = @Translation("An entity field containing a UNIX timestamp of when the entity has been last updated."), - * no_ui = TRUE, - * list_class = "\Drupal\Core\Field\ChangedFieldItemList" - * ) - * * @see \Drupal\Core\Entity\EntityChangedInterface */ +#[FieldType( + id: "changed_test", + label: new TranslatableMarkup("Last changed"), + description: new TranslatableMarkup("An entity field containing a UNIX timestamp of when the entity has been last updated."), + no_ui: TRUE, + list_class: ChangedFieldItemList::class, +)] class ChangedTestItem extends ChangedItem { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ComputedTestCacheableStringItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ComputedTestCacheableStringItem.php index 2ee17c143a8d25d697d24dbb33b70464c94a9568..c0bc5e3f80d8c93599d13f91faaa408ba82c2123 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ComputedTestCacheableStringItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ComputedTestCacheableStringItem.php @@ -2,6 +2,7 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\StringItem; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -9,16 +10,15 @@ /** * Defines the 'string' entity field type with cacheability metadata. - * - * @FieldType( - * id = "computed_test_cacheable_string_item", - * label = @Translation("Test Text (plain string with cacheability)"), - * description = @Translation("A test field containing a plain string value and cacheability metadata."), - * no_ui = TRUE, - * default_widget = "string_textfield", - * default_formatter = "string" - * ) */ +#[FieldType( + id: "computed_test_cacheable_string_item", + label: new TranslatableMarkup("Test Text (plain string with cacheability)"), + description: new TranslatableMarkup("A test field containing a plain string value and cacheability metadata."), + default_widget: "string_textfield", + default_formatter: "string", + no_ui: TRUE +)] class ComputedTestCacheableStringItem extends StringItem { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php index 43e43c1a82205716c23fb04af6822cb51707ec22..dd2c0497e26517af653dcfe476a3e8d9132e0490 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php @@ -2,6 +2,7 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -11,13 +12,12 @@ /** * Defines the 'field_test' entity field type. - * - * @FieldType( - * id = "field_test", - * label = @Translation("Test field item"), - * description = @Translation("A field containing a plain string value."), - * ) */ +#[FieldType( + id: "field_test", + label: new TranslatableMarkup("Test field item"), + description: new TranslatableMarkup("A field containing a plain string value."), +)] class FieldTestItem extends FieldItemBase { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php index 647598d98810285b6a6d3fa933e1e149ac249494..9af51d7f50baf0dc4536e4ae603bcec3b83cf92f 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php @@ -2,6 +2,7 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\StringItem; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -10,15 +11,14 @@ /** * Defines the 'Internal Property' entity test field type. - * - * @FieldType( - * id = "internal_property_test", - * label = @Translation("Internal Property (test)"), - * description = @Translation("A field containing one string, from which two strings are computed (one internal, one not)."), - * default_widget = "string_textfield", - * default_formatter = "string" - * ) */ +#[FieldType( + id: "internal_property_test", + label: new TranslatableMarkup("Internal Property (test)"), + description: new TranslatableMarkup("A field containing one string, from which two strings are computed (one internal, one not)."), + default_widget: "string_textfield", + default_formatter: "string" +)] class InternalPropertyTestFieldItem extends StringItem { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedItem.php index f9606918f5c8c6fe9affffb7f947d7cac141090e..b3c6e05ffd1477ccc10259e8196951fbcd694f0d 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedItem.php @@ -2,6 +2,7 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -9,13 +10,12 @@ /** * Defines the 'serialized_item' entity field type. - * - * @FieldType( - * id = "serialized_item_test", - * label = @Translation("Test serialized field item"), - * description = @Translation("A field containing a serialized string value."), - * ) */ +#[FieldType( + id: "serialized_item_test", + label: new TranslatableMarkup("Test serialized field item"), + description: new TranslatableMarkup("A field containing a serialized string value."), +)] class SerializedItem extends FieldItemBase { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedPropertyItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedPropertyItem.php index 9f5a674c5a0941adaaace238f862603b921764a8..3a49646fa40cc6eba7cf10881399294fd8bae03a 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedPropertyItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SerializedPropertyItem.php @@ -2,6 +2,7 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -9,16 +10,13 @@ /** * Defines the 'serialized_property_item_test' entity field type. - * - * @FieldType( - * id = "serialized_property_item_test", - * label = @Translation("Test serialized property field item"), - * description = @Translation("A field containing a string representing serialized data."), - * serialized_property_names = { - * "value" - * } - * ) */ +#[FieldType( + id: "serialized_property_item_test", + label: new TranslatableMarkup("Test serialized property field item"), + description: new TranslatableMarkup("A field containing a string representing serialized data."), + serialized_property_names: ["value"] +)] class SerializedPropertyItem extends FieldItemBase { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php index 4921dcf481ea1eb7bed84fb3a0f1bdf69580f3fb..3d17c6ed5146a6b9c6b0abfa31033be1adda046e 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php @@ -2,19 +2,20 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; /** * Defines the 'shape' field type. - * - * @FieldType( - * id = "shape", - * label = @Translation("Shape"), - * description = @Translation("Another dummy field type."), - * ) */ +#[FieldType( + id: "shape", + label: new TranslatableMarkup("Shape"), + description: new TranslatableMarkup("Another dummy field type."), +)] class ShapeItem extends FieldItemBase { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItemRequired.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItemRequired.php index fb3876094f55b72ba40d2e7912f0e0c85c447f67..7efd1ad70f2edfd5f78760489d880006ce072635 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItemRequired.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItemRequired.php @@ -2,17 +2,18 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Defines the 'shape_required' field type. - * - * @FieldType( - * id = "shape_required", - * label = @Translation("Shape (required)"), - * description = @Translation("Yet another dummy field type."), - * ) */ +#[FieldType( + id: "shape_required", + label: new TranslatableMarkup("Shape (required)"), + description: new TranslatableMarkup("Yet another dummy field type."), +)] class ShapeItemRequired extends ShapeItem { /** diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SingleInternalPropertyTestFieldItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SingleInternalPropertyTestFieldItem.php index 8d3d25e1f4bdbafdfb0702b4971fc1655d25554f..f28ba3543fb086dc5794eb882e4ebc5f9ecff9eb 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SingleInternalPropertyTestFieldItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/SingleInternalPropertyTestFieldItem.php @@ -2,6 +2,7 @@ namespace Drupal\entity_test\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\StringItem; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -16,15 +17,14 @@ * property name and one internal value are flattened. * * @see \Drupal\entity_test\Plugin\Field\FieldType\InternalPropertyTestFieldItem - * - * @FieldType( - * id = "single_internal_property_test", - * label = @Translation("Single Internal Property (test)"), - * description = @Translation("A field containing one string, from which one internal string is computed."), - * default_widget = "string_textfield", - * default_formatter = "string" - * ) */ +#[FieldType( + id: "single_internal_property_test", + label: new TranslatableMarkup("Single Internal Property (test)"), + description: new TranslatableMarkup("A field containing one string, from which one internal string is computed."), + default_widget: "string_textfield", + default_formatter: "string", +)] class SingleInternalPropertyTestFieldItem extends StringItem { /** diff --git a/core/modules/system/tests/modules/entity_test_update/src/Plugin/Field/FieldType/MultiValueTestItem.php b/core/modules/system/tests/modules/entity_test_update/src/Plugin/Field/FieldType/MultiValueTestItem.php index cb0881809a7266a18b3abaaeb9be2581b3ff1484..76fdb0f8e156d50c5ef9717f601acc31615f26a7 100644 --- a/core/modules/system/tests/modules/entity_test_update/src/Plugin/Field/FieldType/MultiValueTestItem.php +++ b/core/modules/system/tests/modules/entity_test_update/src/Plugin/Field/FieldType/MultiValueTestItem.php @@ -2,19 +2,20 @@ namespace Drupal\entity_test_update\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; +use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; /** * Defines the 'multi_value_test' field type. - * - * @FieldType( - * id = "multi_value_test", - * label = @Translation("Multiple values test"), - * description = @Translation("Another dummy field type."), - * ) */ +#[FieldType( + id: "multi_value_test", + label: new TranslatableMarkup("Multiple values test"), + description: new TranslatableMarkup("Another dummy field type."), +)] class MultiValueTestItem extends FieldItemBase { /** diff --git a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php index d0f0c17f05bf8084f45f67fd7a15183f622bf677..dd97b961d14d560e636cae0c16e4c242fd8fc050 100644 --- a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php +++ b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php @@ -2,23 +2,23 @@ namespace Drupal\telephone\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TypedData\DataDefinition; /** * Plugin implementation of the 'telephone' field type. - * - * @FieldType( - * id = "telephone", - * label = @Translation("Telephone number"), - * description = @Translation("This field stores a telephone number."), - * default_widget = "telephone_default", - * default_formatter = "basic_string" - * ) */ +#[FieldType( + id: "telephone", + label: new TranslatableMarkup("Telephone number"), + description: new TranslatableMarkup("This field stores a telephone number."), + default_widget: "telephone_default", + default_formatter: "basic_string" +)] class TelephoneItem extends FieldItemBase { /** diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php index 5492544db25b408742c9be4ab40cf5462ff5a3cc..5d3ac034b34674f197b7287c8061abc2f571115b 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php @@ -2,27 +2,28 @@ namespace Drupal\text\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'text' field type. - * - * @FieldType( - * id = "text", - * label = @Translation("Text (formatted)"), - * description = { - * @Translation("Ideal for titles and names that need to support markup such as bold, italics or links"), - * @Translation("Efficient storage for short text"), - * @Translation("Requires specifying a maximum length"), - * @Translation("Good for fields with known or predictable lengths"), - * }, - * category = "formatted_text", - * default_widget = "text_textfield", - * default_formatter = "text_default", - * list_class = "\Drupal\text\Plugin\Field\FieldType\TextFieldItemList" - * ) */ +#[FieldType( + id: "text", + label: new TranslatableMarkup("Text (formatted)"), + description: [ + new TranslatableMarkup("Ideal for titles and names that need to support markup such as bold, italics or links"), + new TranslatableMarkup("Efficient storage for short text"), + new TranslatableMarkup("Requires specifying a maximum length"), + new TranslatableMarkup("Good for fields with known or predictable lengths"), + ], + category: "formatted_text", + default_widget: "text_textfield", + default_formatter: "text_default", + list_class: TextFieldItemList::class, +)] class TextItem extends TextItemBase { /** diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php index 3656d05e4fb5b4afa2b3528fc5d3fdbeca867d75..52d29e11d9f9ff12340bf4094c5704012cfe10cf 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php @@ -2,25 +2,26 @@ namespace Drupal\text\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Plugin implementation of the 'text_long' field type. - * - * @FieldType( - * id = "text_long", - * label = @Translation("Text (formatted, long)"), - * description = { - * @Translation("Ideal for longer texts, like body or description without a summary"), - * @Translation("Supports long text without specifying a maximum length"), - * @Translation("May use more storage and be slower for searching and sorting"), - * }, - * category = "formatted_text", - * default_widget = "text_textarea", - * default_formatter = "text_default", - * list_class = "\Drupal\text\Plugin\Field\FieldType\TextFieldItemList" - * ) */ +#[FieldType( + id: "text_long", + label: new TranslatableMarkup("Text (formatted, long)"), + description: [ + new TranslatableMarkup("Ideal for longer texts, like body or description without a summary"), + new TranslatableMarkup("Supports long text without specifying a maximum length"), + new TranslatableMarkup("May use more storage and be slower for searching and sorting"), + ], + category: "formatted_text", + default_widget: "text_textarea", + default_formatter: "text_default", + list_class: TextFieldItemList::class, +)] class TextLongItem extends TextItemBase { /** diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php index 9d43920520cf850cd6d46b87ac1238243ad8efbb..f099a53a93c2aa10ee6b0103fdf13521292236ac 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php @@ -2,29 +2,29 @@ namespace Drupal\text\Plugin\Field\FieldType; +use Drupal\Core\Field\Attribute\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TypedData\DataDefinition; /** * Plugin implementation of the 'text_with_summary' field type. - * - * @FieldType( - * id = "text_with_summary", - * label = @Translation("Text (formatted, long, with summary)"), - * description = { - * @Translation("Ideal for longer texts, like body or description with a summary"), - * @Translation("Allows specifying a summary for the text"), - * @Translation("Supports long text without specifying a maximum length"), - * @Translation("May use more storage and be slower for searching and sorting"), - * }, - * category = "formatted_text", - * default_widget = "text_textarea_with_summary", - * default_formatter = "text_default", - * list_class = "\Drupal\text\Plugin\Field\FieldType\TextFieldItemList" - * ) */ +#[FieldType( + id: "text_with_summary", + label: new TranslatableMarkup("Text (formatted, long, with summary)"), + description: [ + new TranslatableMarkup("Ideal for longer texts, like body or description with a summary"), + new TranslatableMarkup("Allows specifying a summary for the text"), + new TranslatableMarkup("Supports long text without specifying a maximum length"), + new TranslatableMarkup("May use more storage and be slower for searching and sorting"), + ], + category: "formatted_text", + default_widget: "text_textarea_with_summary", + default_formatter: "text_default", + list_class: TextFieldItemList::class, +)] class TextWithSummaryItem extends TextItemBase { /**