You are here

function hook_drafty_predelete_revision in Drafty 7

Allow access to information attached to a revision before it is deleted.

Parameters

string $entity_type: The entity type.

int $entity_id: The entity ID.

int $revision_id: The revision ID to be deleted.

int $replaced_by: The new revision ID that is replacing the one that is about to be deleted.

1 invocation of hook_drafty_predelete_revision()
drafty_queue_delete_revision in ./drafty.module
Callback function to delete a single temporary-draft revision.

File

./drafty.api.php, line 20
API documentation for drafty.

Code

function hook_drafty_predelete_revision($entity_type, $entity_id, $revision_id, $replaced_by) {
  if ($entity_type == 'node') {

    // Preserve the revision timestamp.
    $revision = node_load($entity_id, $revision_id);
    db_update('node_revision')
      ->fields(array(
      'timestamp' => $revision->revision_timestamp,
    ))
      ->condition('vid', $replaced_by)
      ->execute();
  }
}