Fields are now bound to a specific entity type (they are still shareable between bundles) and the storage controller for that entity type handles the CRUD operation of the whole entity. It is possible to create fields named the same on different entity types, these will be completely separate fields not sharing their settings.
Despite the changes are massive internally, a lot of entity handling did not change.
$node->body->value still works, entities are saved by
$node->save() etc. Only code that handled actual field information separately from entities will need to change.
Field information changes
field_info_fields()returns a list keyed by field UUID instead of field names, as field names are no longer unique.
field_read_field()require an additional
field_info_field_map()returns a list keyed by entity_type, then field name.
$field->getBundles()returns a list of entity bundle names (was keyed by entity type previously)
$field ConfigEntity changes
The primary identifier of the
$field entity previously was the
field_name. Now there's a
name instead but that's not enough -- fields are no longer shareable among entity types and so
entity_type is part of the primary identifier:
$field = entity_create('field_config', array('entity_type' => $entity_type, 'name' => $name));
these two keys (and properties on the resulting
$fieldentities) specify which field are we working with.
Field storage backends are gone
Storing everything is the responsibility of the entity storage controller. An abstract
Drupal\Core\Entity\FieldableEntityStorageControllerBase is provided which has protected methods for reading / writing field values:
saveFieldItems()... Those are wrappers that contain the generic handling of the "field data cache". Actual storage processing is delegated to
doSaveFieldItems() methods that are up to each actual storage class to provide. These methods are implemented
DatabaseStorageController by the same storage logic that was previously in field_sql_storage.module. There is also a
Drupal\Core\Entity\FieldableEntityStorageControllerInterface which defines methods to deal with configurable field & bundle CRUD.
Also, all of the field storage hooks were removed:
Most of field.attach.inc is gone
field_attach_delete_revision functions are gone without replacement. Associated hooks
hook_field_attach_delete_revision are gone as well.