Updated: Comment #61
Different things and classes are currently called Field.
- The field config entity that contains the basic field definition (Drupal\field\Entity\Field)
- The field objects on the entity that contains the field items and their values (Drupal\Core\Entity\Field\Field)
There are also two more classes that are called entity:
- \Drupal\field\Field which is used to access the field info service (Field::fieldInfo())
- A views field class to display fields.
There were also discussions around the FieldItem class and what exactly "field values" are.
After *long* discussions at the #HardProblems sprint on sunday, we agreed on the following terminology and class names:
- We figured the only confusing term right now is "Field", while we field items and field item properties is not confusing to Drupal folks.
- The suggestion of going with "field values" instead of "field items" was discussed. However, "values" would apply to each layer (field item list, field items, field item properties) so is ambiguous. Contrary, item has quite a Drupal history is all over the place, specific and clear, so we stay with that.
- The Field class on entities is a list of FieldItem's, so will be renamed to FieldItemList, FieldItemListInterface and also all subclasses accordingly. A common way to refer to it is "FieldItemListInterface $items". FieldItems was discussed, but was considered to be hard to distinguish from FieldItem This is what this patch does.
- The meaning of what a "field" is depends on the context. If the context is clear, it's ok to refer to it as field/$field. If the context is not clear, e.g. when it's about the field definition, $field_definition/FieldDefinition should be used.
- Therefore, FieldDefinitionInterface, FieldDefinition and related methods will not be renamed.
- The static Field class will be renamed in
- The Field (field_entity) will be renamed to FieldConfig (field_config), FieldInstance (field_instance) will be renamed to FieldInstanceConfig (field_instance_config)
Class overview after the rename:
User interface changes
As outlined above. \Drupal\Core\Entity\Field\Field => FieldItemList, \Drupal\Core\Entity\Field\FieldInterface => FieldItemListInterface
All other API changes will be done in other issues.
Original report by @yched
There has been a lot of uncertainty (understatement) about terminology in EntityNG / Field API, mostly because the word/class "Field" is being used:
- in EntityNG, to point to the objects holding values on a specific entity ($node_1->body)
- in "legacy" Field API, to point to definition structures ("the 'body' field on article nodes)
The initial direction (see
- this approach has been shot down after a while - see
- turns out EntityNG intends to rename the "value objects" from Field to FieldItemList anyway -
So this issue is about acknowledging that "Field" is about field definitions, and deriving a clear and sound naming scheme from there - hopefully once and for all...
If "field" stays "a field definition", then:
- it seems it would make sense to rename the "generic" Drupal\Core\Entity\Field\FieldDefinitionInterface used by widgets and formatters, to simply FieldInterface.
- if so, then this clashes with Drupal\field\Plugin\Core\Entity\FieldInterface (the interface for the "configurable field" ConfigEntity : Field) - and one interface extends the other :-).
So we'd still need to rename Field API's config entity classes for "definitions of configurable fields".
Note: this proposal should imply very little variable renames, which is definitely a good thing.
- Abstract "field definition" interface added by
Drupal\Core\Entity\Field\FieldDefinitionInterface --> FieldInterface
- "field definition" class for "base fields" being added at
Drupal\Core\Entity\Field\FieldDefinition (current name in the patch) --> Field ? BaseField ?
- "configurable field" ConfigEntities handled by field.module:
Drupal\field\FieldInterface --> ConfigurableFieldInterface
Drupal\field\FieldInstanceInterface --> ConfigurableFieldInstanceInterface
Drupal\field\Plugin\Core\Entity\Field --> ConfigurableField - entity_type 'field' - CMI: field.field.*
Drupal\field\Plugin\Core\Entity\FieldInstance --> ConfigurableFieldInstance - entity_type 'field_instance' - CMI: field.instance.*
no need to rename existing $field / $instance variables, which was probably 80% of the huge patch in .
- Field values:
Drupal\Core\Entity\Field\Field --> FieldItemList (as per )
Drupal\Core\Entity\Field\FieldInterface --> FieldItemListInterface
Drupal\Core\Entity\Field\FieldItem --> unchanged
Drupal\Core\Entity\Field\FieldItemBase --> unchanged
Drupal\Core\Entity\Field\FieldItemInterface --> unchanged
FieldItemList/FieldItemBase::getFieldDefinition() --> getField() (returns a FieldInterface : "abstract field definition")
- "Configurable field" values:
Drupal\field\Plugin\Type\FieldType\ConfigField -> ConfigurableFieldItemList (that class might turn useless after )
Drupal\field\Plugin\Type\FieldType\ConfigFieldInterface -> ConfigurableFieldItemListInterface (same)
Drupal\field\Plugin\Type\FieldType\ConfigFieldItemBase -> ConfigurableFieldItemBase
Drupal\field\Plugin\Type\FieldType\ConfigFieldItemInterface -> ConfigurableFieldItemInterface
|FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch rename_field-2051923-73.patch. Unable to apply patch. See the log in the details link for more information.|
|PASSED: [[SimpleTest]]: [MySQL] 59,186 pass(es).|
|PASSED: [[SimpleTest]]: [MySQL] 58,824 pass(es).|