public function FieldCollectionItemEntity::deleteRevision

cis7 field_collection.module public FieldCollectionItemEntity::deleteRevision($skip_host_update = FALSE)
cle7 field_collection.module public FieldCollectionItemEntity::deleteRevision($skip_host_update = FALSE)
elmsmedia7 field_collection.module public FieldCollectionItemEntity::deleteRevision($skip_host_update = FALSE)
icor7 field_collection.module public FieldCollectionItemEntity::deleteRevision($skip_host_update = FALSE)
meedjum_blog7 field_collection.module public FieldCollectionItemEntity::deleteRevision($skip_host_update = FALSE)
mooc7 field_collection.module public FieldCollectionItemEntity::deleteRevision($skip_host_update = FALSE)

Intelligently delete a field collection item revision.

If a host entity is revisioned with its field collection items, deleting a field collection item on the default revision of the host should not delete the collection item from archived revisions too. Instead, we delete the current default revision and archive the field collection.

If no revisions are left or the host is not revisionable, the whole item is deleted.

File

sites/all/modules/ulmus/field_collection/field_collection.module, line 542
Module implementing field collection field type.

Class

FieldCollectionItemEntity
Class for field_collection_item entities.

Code

public function deleteRevision($skip_host_update = FALSE) {
  if (!$this->revision_id) {
    return;
  }
  $info = entity_get_info($this->hostEntityType());
  if (empty($info['entity keys']['revision']) || !$this->hostEntity()) {
    return $this->delete();
  }
  if (!$skip_host_update) {
    // Just remove the item from the host, which cares about deleting the
    // item (depending on whether the update creates a new revision).
    $this->deleteHostEntityReference();
  }
  elseif (!$this->isDefaultRevision()) {
    entity_revision_delete('field_collection_item', $this->revision_id);
  }
  // If deleting the default revision, take care!
  else {
    $row = db_select('field_collection_item_revision', 'r')->fields('r')->condition('item_id', $this->item_id)->condition('revision_id', $this->revision_id, '<>')->execute()->fetchAssoc();
    // If no other revision is left, delete. Else archive the item.
    if (!$row) {
      $this->delete();
    }
    else {
      // Make the other revision the default revision and archive the item.
      db_update('field_collection_item')->fields(array('archived' => 1, 'revision_id' => $row['revision_id']))->condition('item_id', $this->item_id)->execute();
      entity_get_controller('field_collection_item')->resetCache(array($this->item_id));
      entity_revision_delete('field_collection_item', $this->revision_id);
    }
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.