You are here

function message_digest_entity_predelete in Message Digest 8

Implements hook_entity_predelete().

Cleans up any references to the entity that is being deleted.

File

./message_digest.module, line 98
Hook implementations for the Message Digest module.

Code

function message_digest_entity_predelete(EntityInterface $entity) {
  switch ($entity
    ->getEntityTypeId()) {
    case 'message':
      Database::getConnection()
        ->delete('message_digest')
        ->condition('mid', $entity
        ->id())
        ->execute();
      break;
    case 'user':
      Database::getConnection()
        ->delete('message_digest')
        ->condition('receiver', $entity
        ->id())
        ->execute();
      break;
  }
}