diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index b07795f..db52530 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -371,11 +371,11 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) { if (is_array($definition)) { $definition = FieldDefinition::createFromOldStyleDefinition($definition); } - // For manually defined fields, make sure the field name is set. + // Automatically set the field-name for non-configurable fields. if ($definition instanceof FieldDefinition) { $definition->setFieldName($field_name); } - // Ensure ID and langcode fields are never made translatable. + // Ensure all untranslatable fields are not defined as translatable. if (isset($untranslatable_fields[$field_name]) && $definition->isFieldTranslatable()) { throw new \LogicException(format_string('The @field field cannot be translatable.', array('@field' => $definition->getFieldLabel()))); } diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldType.php b/core/lib/Drupal/Core/Field/Annotation/FieldType.php index dc7e32b..67f64bc 100644 --- a/core/lib/Drupal/Core/Field/Annotation/FieldType.php +++ b/core/lib/Drupal/Core/Field/Annotation/FieldType.php @@ -119,4 +119,14 @@ class FieldType extends DataType { */ public $list_type = 'field_item_list'; + /** + * The typed data class used for wrapping multiple data items of the type. + * Must implement the \Drupal\Core\TypedData\ListInterface. + * + * @todo Right now, $list_class support is for backwards compatiblity only. + * After moving all usages to $list_type, remove this. + * + * @var string + */ + public $list_class = '\Drupal\Core\Field\Plugin\DataType\FieldItemList'; } diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php index e5b233b..4dca17a 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php +++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php @@ -14,10 +14,9 @@ * Defines an interface for entity field definitions. * * An entity field is a data object that holds the values of a particular field - * for a particular entity (see - * \Drupal\Core\Field\FieldItemListInterface). For example, $node_1->body - * and $node_2->body contain different data and therefore are different field - * objects. + * for a particular entity (see \Drupal\Core\Field\FieldItemListInterface). For + * example, $node_1->body and $node_2->body contain different data and therefore + * are different field objects. * * In contrast, an entity field *definition* is an object that returns * information *about* a field (e.g., its type and settings) rather than its diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index 70ff483..4645936 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -8,8 +8,6 @@ namespace Drupal\Core\Field; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\Plugin\DataType\Map; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\user; @@ -25,13 +23,6 @@ abstract class FieldItemBase extends Map implements FieldItemInterface { /** - * The field's definition. - * - * @var \Drupal\Core\Field\FieldDefinitionInterface - */ - protected $definition; - - /** * Overrides \Drupal\Core\TypedData\TypedData::__construct(). */ public function __construct($definition, $name = NULL, TypedDataInterface $parent = NULL) { diff --git a/core/lib/Drupal/Core/Field/Plugin/DataType/FieldItemList.php b/core/lib/Drupal/Core/Field/Plugin/DataType/FieldItemList.php index 31ec4e1..93c83ba 100644 --- a/core/lib/Drupal/Core/Field/Plugin/DataType/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/Plugin/DataType/FieldItemList.php @@ -44,7 +44,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface { protected $langcode = Language::LANGCODE_DEFAULT; /** - * Overrides TypedData::__construct(). + * {@inheritdoc} */ public function __construct($definition, $name = NULL, TypedDataInterface $parent = NULL) { parent::__construct($definition, $name, $parent); diff --git a/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php index acfa4ea..6597f3c 100644 --- a/core/lib/Drupal/Core/TypedData/TypedData.php +++ b/core/lib/Drupal/Core/TypedData/TypedData.php @@ -51,6 +51,10 @@ * root of a typed data tree. Defaults to NULL. * * @see \Drupal\Core\TypedData\TypedDataManager::create() + * + * @todo When \Drupal\Core\Config\TypedConfigManager has been fixed to use + * class-based definitions, type-hint $definition to + * DataDefinitionInterface. */ public function __construct($definition, $name = NULL, TypedDataInterface $parent = NULL) { $this->definition = $definition; diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 37e4a6b..c89c6ec 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -122,7 +122,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ // fields support translation. Whether they are actually enabled is // determined through our settings. As a consequence only fields // that support translation can be enabled or disabled. - elseif (isset($field_settings[$field_name]) || !empty($definition['translatable'])) { + elseif (isset($field_settings[$field_name]) || $definition->isFieldTranslatable()) { $form['settings'][$entity_type][$bundle]['fields'][$field_name] = array( '#label' => $definition['label'], '#type' => 'checkbox', diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index 5c213dd..2bedb65 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -926,13 +926,13 @@ function field_language(EntityInterface $entity, $field_name = NULL, $langcode = if (!isset($field_name)) { $display_langcodes = array(); foreach ($definitions as $name => $definition) { - if (!empty($definition['configurable'])) { + if ($definition->isFieldConfigurable()) { $display_langcodes[$name] = $translatable ? $langcode : Language::LANGCODE_NOT_SPECIFIED; } } return $display_langcodes; } - elseif (!empty($definitions[$field_name]['configurable'])) { + elseif ($definitions[$field_name]>isFieldConfigurable()) { return $translatable ? $langcode : Language::LANGCODE_NOT_SPECIFIED; } } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 9c46f5b..73ac825 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -194,8 +194,9 @@ function field_entity_field_info($entity_type) { foreach (field_info_instances($entity_type) as $bundle_name => $instances) { $optional = $bundle_name != $entity_type; - // @todo: Improve hook_entity_field_info() so that it can take field - // instance also. + // @todo: Improve hook_entity_field_info() to allow per-bundle field + // definitions, such that we can pass on field instances as field + // definitions here. foreach ($instances as $field_name => $instance) { if ($optional) { diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php index 4abf5d3..7be07a9 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php @@ -11,7 +11,6 @@ use Drupal\Core\TypedData\ContextAwareInterface; use Drupal\Core\Config\Schema\Element; use Drupal\Core\Config\Schema\ArrayElement; -use Drupal\Core\TypedData\DataDefinitionInterface; /** * Defines the locale configuration wrapper object.