diff --git a/core/lib/Drupal/Core/Entity/Annotation/FieldType.php b/core/lib/Drupal/Core/Entity/Annotation/FieldType.php index 1de71b5..0ab92a7 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/FieldType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/FieldType.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity\Annotation; use Drupal\Component\Annotation\Plugin; +use Drupal\Core\TypedData\Annotation\DataType; /** * Defines a FieldType annotation object. @@ -17,7 +18,7 @@ * * @Annotation */ -class FieldType extends Plugin { +class FieldType extends DataType { /** * The plugin ID. @@ -103,8 +104,6 @@ class FieldType extends Plugin { /** * A boolean stating that fields of this type are configurable. * - * @todo: Make field module respect this. - * * @var boolean */ public $configurable = TRUE; @@ -112,10 +111,16 @@ class FieldType extends Plugin { /** * A boolean stating that fields of this type cannot be created through the UI. * - * If TRUE, fields of this type can only be created programmatically. + * If TRUE or the field type is not configurable, fields of this type can only + * be created programmatically. * * @var boolean */ public $no_ui = FALSE; + /** + * {@inheritdoc} + */ + public $list_class; + } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index d4b4ea5..4f8ccbc 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Entity; use Drupal\Component\Uuid\Uuid; -use Drupal\Core\Entity\Plugin\DataType\EntityReferenceItem; +use Drupal\Core\Entity\Plugin\field\field_type\EntityReferenceItem; use Drupal\Core\Language\Language; use Drupal\Core\TypedData\TranslatableInterface; use Drupal\Core\TypedData\TypedDataInterface; diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 67e5690..18a5f67 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -477,8 +477,16 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) { } else { $class = $this->factory->getPluginClass($entity_type, $this->getDefinition($entity_type)); + + $base_definitions = $class::baseFieldDefinitions($entity_type); + foreach ($base_definitions as &$base_definition) { + // Support old-style field types to avoid that all base field + // definitions need to be changed. + // @todo: Remove after https://drupal.org/node/2047229. + $base_definition['type'] = preg_replace('/(.+)_field/', 'field_item:$1', $base_definition['type']); + } $this->entityFieldInfo[$entity_type] = array( - 'definitions' => $class::baseFieldDefinitions($entity_type), + 'definitions' => $base_definitions, // Contains definitions of optional (per-bundle) fields. 'optional' => array(), // An array keyed by bundle name containing the optional fields added diff --git a/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php index 5269769..1143ddd 100644 --- a/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity\Field; +use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManager; @@ -25,7 +26,6 @@ class FieldTypePluginManager extends DefaultPluginManager { protected $defaults = array( 'settings' => array(), 'instance_settings' => array(), - 'list_class' => '\Drupal\field\Plugin\Type\FieldType\ConfigField', ); /** @@ -52,6 +52,20 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac } /** + * {@inheritdoc} + */ + public function processDefinition(&$definition, $plugin_id) { + parent::processDefinition($definition, $plugin_id); + if ($definition['configurable']) { + $definition['list_class'] = '\Drupal\field\Plugin\Type\FieldType\ConfigField'; + } + else { + $definition['list_class'] = '\Drupal\Core\Entity\Field\Field'; + } + } + + + /** * Returns the default field-level settings for a field type. * * @param string $type @@ -81,4 +95,27 @@ public function getDefaultInstanceSettings($type) { return isset($info['instance_settings']) ? $info['instance_settings'] : array(); } + /** + * Gets the definition of all field types. + * + * @param Boolean $configurable + * Configurable flag to indicate whether return configurable field types. + * + * @return array + * An array of field type definitions. + */ + public function getDefinitions($configurable = NULL) { + $definitions = $this->getCachedDefinitions(); + if (!isset($definitions)) { + $definitions = $this->findDefinitions(); + $this->setCachedDefinitions($definitions); + } + if ($configurable) { + return array_filter($this->definitions, function ($defintion) { + return $defintion['configurable']; + }); + } + return $definitions; + } + } diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/BooleanItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/BooleanItem.php similarity index 66% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/BooleanItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/BooleanItem.php index 367cc74..e60cdd4 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/BooleanItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/BooleanItem.php @@ -2,23 +2,21 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\BooleanItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\BooleanItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Field\FieldItemBase; /** - * Defines the 'boolean_field' entity field item. + * Defines the 'boolean' entity field type. * - * @DataType( - * id = "boolean_field", - * label = @Translation("Boolean field item"), + * @FieldType( + * id = "boolean", + * label = @Translation("Boolean"), * description = @Translation("An entity field containing a boolean value."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * configurable = false * ) */ class BooleanItem extends FieldItemBase { diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/DateItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/DateItem.php similarity index 66% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/DateItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/DateItem.php index 3fd9aa6..5245abb 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/DateItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/DateItem.php @@ -2,23 +2,21 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\DateItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\DateItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Field\FieldItemBase; /** - * Defines the 'date_field' entity field item. + * Defines the 'date' entity field type. * - * @DataType( - * id = "date_field", - * label = @Translation("Date field item"), + * @FieldType( + * id = "date", + * label = @Translation("Date"), * description = @Translation("An entity field containing a date value."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * configurable = false * ) */ class DateItem extends FieldItemBase { diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EmailItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/EmailItem.php similarity index 67% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/EmailItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/EmailItem.php index 3732b73..190a36e 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EmailItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/EmailItem.php @@ -2,24 +2,21 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\EmailItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\EmailItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; -use Drupal\Core\Entity\Field\FieldItemBase; use Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem; /** - * Defines the 'email_field' entity field item. + * Defines the 'email' entity field type. * - * @DataType( - * id = "email_field", - * label = @Translation("E-mail field item"), + * @FieldType( + * id = "email", + * label = @Translation("E-mail"), * description = @Translation("An entity field containing an e-mail value."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * configurable = false * ) */ class EmailItem extends LegacyConfigFieldItem { diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReferenceItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/EntityReferenceItem.php similarity index 92% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReferenceItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/EntityReferenceItem.php index 69b2400..4891b5e 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/EntityReferenceItem.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\EntityReferenceItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\EntityReferenceItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; use Drupal\Core\TypedData\Annotation\DataType; use Drupal\Core\Annotation\Translation; @@ -13,7 +13,7 @@ use Drupal\Core\TypedData\TypedDataInterface; /** - * Defines the 'entity_reference_item' entity field item. + * Defines the 'entity_reference' entity field type. * * Supported settings (below the definition's 'settings' key) are: * - target_type: The entity type to reference. Required. @@ -21,11 +21,11 @@ * may be referenced. May be set to an single bundle, or to an array of * allowed bundles. * - * @DataType( - * id = "entity_reference_field", - * label = @Translation("Entity reference field item"), + * @FieldType( + * id = "entity_reference", + * label = @Translation("Entity reference"), * description = @Translation("An entity field containing an entity reference."), - * list_class = "\Drupal\Core\Entity\Field\Field", + * configurable = false, * constraints = {"ValidReference" = TRUE} * ) */ diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/IntegerItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/IntegerItem.php similarity index 66% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/IntegerItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/IntegerItem.php index 4eb4db3..5142dfc 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/IntegerItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/IntegerItem.php @@ -2,23 +2,21 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\IntegerItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\IntegerItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Field\FieldItemBase; /** - * Defines the 'integer_field' entity field item. + * Defines the 'integer' entity field type. * - * @DataType( - * id = "integer_field", - * label = @Translation("Integer field item"), + * @FieldType( + * id = "integer", + * label = @Translation("Integer"), * description = @Translation("An entity field containing an integer value."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * configurable = false * ) */ class IntegerItem extends FieldItemBase { diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/LanguageItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/LanguageItem.php similarity index 88% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/LanguageItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/LanguageItem.php index 68526f5..e0ec10b 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/LanguageItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/LanguageItem.php @@ -2,24 +2,22 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\LanguageItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\LanguageItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Field\FieldItemBase; use Drupal\Core\Language\Language; /** - * Defines the 'language_field' entity field item. + * Defines the 'language' entity field item. * - * @DataType( - * id = "language_field", - * label = @Translation("Language field item"), + * @FieldType( + * id = "language", + * label = @Translation("Language"), * description = @Translation("An entity field referencing a language."), - * list_class = "\Drupal\Core\Entity\Field\Field", + * configurable = false, * constraints = { * "ComplexData" = { * "value" = {"Length" = {"max" = 12}} diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/StringItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/StringItem.php similarity index 66% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/StringItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/StringItem.php index 1f22d49..a0008a9 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/StringItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/StringItem.php @@ -2,23 +2,21 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\StringItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\StringItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Field\FieldItemBase; /** - * Defines the 'string_field' entity field item. + * Defines the 'string' entity field type. * - * @DataType( - * id = "string_field", - * label = @Translation("String field item"), + * @FieldType( + * id = "string", + * label = @Translation("String"), * description = @Translation("An entity field containing a string value."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * configurable = false * ) */ class StringItem extends FieldItemBase { diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/UriItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/UriItem.php similarity index 65% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/UriItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/UriItem.php index fc398a2..2a268c8 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/UriItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/UriItem.php @@ -2,23 +2,21 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\UriItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\UriItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Field\FieldItemBase; /** - * Defines the 'uri_field' entity field item. + * Defines the 'uri' entity field type. * - * @DataType( - * id = "uri_field", - * label = @Translation("URI field item"), + * @FieldType( + * id = "uri", + * label = @Translation("URI"), * description = @Translation("An entity field containing a URI."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * configurable = false * ) */ class UriItem extends FieldItemBase { diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/UuidItem.php b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/UuidItem.php similarity index 61% rename from core/lib/Drupal/Core/Entity/Plugin/DataType/UuidItem.php rename to core/lib/Drupal/Core/Entity/Plugin/field/field_type/UuidItem.php index 737409d..6e84406 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/UuidItem.php +++ b/core/lib/Drupal/Core/Entity/Plugin/field/field_type/UuidItem.php @@ -2,25 +2,23 @@ /** * @file - * Contains \Drupal\Core\Entity\Plugin\DataType\UuidItem. + * Contains \Drupal\Core\Entity\Plugin\field\field_type\UuidItem. */ -namespace Drupal\Core\Entity\Plugin\DataType; +namespace Drupal\Core\Entity\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Component\Uuid\Uuid; /** - * Defines the 'uuid_field' entity field item. + * Defines the 'uuid' entity field type. * * The field uses a newly generated UUID as default value. * - * @DataType( - * id = "uuid_field", - * label = @Translation("UUID field item"), + * @FieldType( + * id = "uuid", + * label = @Translation("UUID"), * description = @Translation("An entity field containing a UUID."), - * list_class = "\Drupal\Core\Entity\Field\Field", + * configurable = false, * constraints = { * "ComplexData" = { * "value" = {"Length" = {"max" = 128}} diff --git a/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php b/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php index b346c4b..d34a559 100644 --- a/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php +++ b/core/modules/email/lib/Drupal/email/Plugin/field/field_type/ConfigurableEmailItem.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\Annotation\FieldType; use Drupal\Core\Annotation\Translation; -use Drupal\Core\Entity\Plugin\DataType\EmailItem; +use Drupal\Core\Entity\Plugin\field\field_type\EmailItem; use Drupal\field\FieldInterface; /** diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php index 6b3c137..18cb2e0 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/ConfigEntityReferenceItemBase.php @@ -7,7 +7,7 @@ namespace Drupal\field\Plugin\Type\FieldType; -use Drupal\Core\Entity\Plugin\DataType\EntityReferenceItem; +use Drupal\Core\Entity\Plugin\field\field_type\EntityReferenceItem; use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemInterface; use Drupal\field\FieldInterface; use Drupal\field\FieldInstanceInterface; diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php index 2fc45a4..2c8b362 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/LegacyFieldTypeDiscoveryDecorator.php @@ -63,11 +63,10 @@ public function getDefinitions() { $function = $module . '_field_info'; if (function_exists($function)) { foreach ($function() as $plugin_id => $definition) { - $definition += array( - 'id' => $plugin_id, - 'provider' => $module, - 'list_class' => '\Drupal\field\Plugin\field\field_type\LegacyConfigField', - ); + $definition['id'] = $plugin_id; + $definition['provider'] = $module; + $definition['configurable'] = TRUE; + $definition['list_class'] = '\Drupal\field\Plugin\field\field_type\LegacyConfigField'; $definitions[$plugin_id] = $definition; } } diff --git a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php index 2ee23f4..01c29d2 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php @@ -9,7 +9,7 @@ use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Annotation\FieldType; -use Drupal\Core\Entity\Plugin\DataType\EntityReferenceItem; +use Drupal\Core\Entity\Plugin\field\field_type\EntityReferenceItem; use Drupal\field\FieldInterface; use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemInterface; diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index 793c595..923bcb0 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -83,7 +83,7 @@ function node_access_test_permission() { function node_access_test_entity_field_info($entity_type) { if ($entity_type === 'node') { $info['definitions']['private'] = array( - 'type' => 'boolean_field', + 'type' => 'field_item:boolean', 'label' => t('Private'), 'computed' => TRUE, 'list' => TRUE, diff --git a/core/modules/path/lib/Drupal/path/Plugin/DataType/PathItem.php b/core/modules/path/lib/Drupal/path/Plugin/field/field_type/PathItem.php similarity index 70% rename from core/modules/path/lib/Drupal/path/Plugin/DataType/PathItem.php rename to core/modules/path/lib/Drupal/path/Plugin/field/field_type/PathItem.php index e72e3a7..e796bd0 100644 --- a/core/modules/path/lib/Drupal/path/Plugin/DataType/PathItem.php +++ b/core/modules/path/lib/Drupal/path/Plugin/field/field_type/PathItem.php @@ -2,23 +2,21 @@ /** * @file - * Contains \Drupal\path\Plugin\DataType\PathItem. + * Contains \Drupal\path\Plugin\field\field_type\PathItem. */ -namespace Drupal\path\Plugin\DataType; +namespace Drupal\path\Plugin\field\field_type; -use Drupal\Core\TypedData\Annotation\DataType; -use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\Field\FieldItemBase; /** - * Defines the 'path_field' entity field item. + * Defines the 'path' entity field type. * - * @DataType( - * id = "path_field", - * label = @Translation("Path field item"), + * @FieldType( + * id = "path", + * label = @Translation("Path"), * description = @Translation("An entity field containing a path alias and related data."), - * list_class = "\Drupal\Core\Entity\Field\Field" + * configurable = false * ) */ class PathItem extends FieldItemBase { diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 984650a..f062807 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -216,7 +216,7 @@ function path_form_taxonomy_term_form_alter(&$form, $form_state) { function path_entity_field_info($entity_type) { if ($entity_type === 'taxonomy_term' || $entity_type === 'node') { $info['definitions']['path'] = array( - 'type' => 'path_field', + 'type' => 'field_item:path', 'label' => t('The path alias'), 'computed' => TRUE, 'list' => TRUE,