You are here

function comment_alter_entity_revision_delete in Comment Alter 8

Implements hook_entity_revision_delete().

File

./comment_alter.module, line 565
Allows to alter entities from comment form.

Code

function comment_alter_entity_revision_delete(EntityInterface $entity) {

  // Delete entries from the comment_alter table when a parent entity revision
  // is deleted.
  $conditions = new \Drupal\Core\Database\Query\Condition('OR');
  if ($entity
    ->getEntityType()
    ->hasKey('revision')) {
    \Drupal::database()
      ->delete('comment_alter')
      ->condition('parent_entity_type', $entity
      ->getEntityTypeId())
      ->condition($conditions
      ->condition('old_vid', $entity
      ->getRevisionId())
      ->condition('new_vid', $entity
      ->getRevisionId()))
      ->execute();
  }
}