function field_attach_delete_revision

Delete field data for a single revision of an existing entity. The passed entity must have a revision ID attribute.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity with fields to save.

Related topics

1 call to field_attach_delete_revision()
FieldAttachStorageTest::testFieldAttachDelete in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
Test field_attach_delete().
4 string references to 'field_attach_delete_revision'
DatabaseStorageController::invokeHook in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
Invokes a hook on behalf of the entity.
DatabaseStorageControllerNG::invokeHook in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::invokeHook().
NodeStorageController::invokeHook in drupal/core/modules/node/lib/Drupal/node/NodeStorageController.php
Overrides Drupal\Core\Entity\DatabaseStorageController::invokeHook().
UserStorageController::invokeHook in drupal/core/modules/user/lib/Drupal/user/UserStorageController.php
Overrides DatabaseStorageController::invokeHook().

File

drupal/core/modules/field/field.attach.inc, line 1320
Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'.

Code

function field_attach_delete_revision(EntityInterface $entity) {

  // Ensure we are working with a BC mode entity.
  $entity = $entity
    ->getBCEntity();
  _field_invoke('delete_revision', $entity);

  // Collect the storage backends used by the fields in the entities.
  $storages = array();
  foreach (field_info_instances($entity
    ->entityType(), $entity
    ->bundle()) as $instance) {
    $field = field_info_field_by_id($instance['field_id']);
    $field_id = $field['uuid'];
    $storages[$field['storage']['type']][$field_id] = $field_id;
  }

  // Field storage backends delete their data.
  foreach ($storages as $storage => $fields) {
    $storage_info = field_info_storage_types($storage);
    module_invoke($storage_info['module'], 'field_storage_delete_revision', $entity, $fields);
  }

  // Let other modules act on deleting the revision.
  module_invoke_all('field_attach_delete_revision', $entity);
}