You are here

function mentions_entity_delete in Open Social 8.2

Same name and namespace in other branches
  1. 8.9 modules/custom/mentions/mentions.module \mentions_entity_delete()
  2. 8 modules/custom/mentions/mentions.module \mentions_entity_delete()
  3. 8.3 modules/custom/mentions/mentions.module \mentions_entity_delete()
  4. 8.4 modules/custom/mentions/mentions.module \mentions_entity_delete()
  5. 8.5 modules/custom/mentions/mentions.module \mentions_entity_delete()
  6. 8.6 modules/custom/mentions/mentions.module \mentions_entity_delete()
  7. 8.7 modules/custom/mentions/mentions.module \mentions_entity_delete()
  8. 8.8 modules/custom/mentions/mentions.module \mentions_entity_delete()
  9. 10.3.x modules/custom/mentions/mentions.module \mentions_entity_delete()
  10. 10.0.x modules/custom/mentions/mentions.module \mentions_entity_delete()
  11. 10.1.x modules/custom/mentions/mentions.module \mentions_entity_delete()
  12. 10.2.x modules/custom/mentions/mentions.module \mentions_entity_delete()

Implements hook_entity_delete().

File

modules/custom/mentions/mentions.module, line 103
Code for the mentions module.

Code

function mentions_entity_delete(EntityInterface $entity) {
  $mention_ids = \Drupal::entityQuery('mentions')
    ->condition('entity_id', $entity
    ->id())
    ->condition('entity_type', $entity
    ->getEntityTypeId())
    ->execute();
  $storage_handler = \Drupal::entityTypeManager()
    ->getStorage('mentions');
  $entities = $storage_handler
    ->loadMultiple($mention_ids);
  $storage_handler
    ->delete($entities);
  $event_dispatcher = \Drupal::service('event_dispatcher');
  $event_dispatcher
    ->dispatch('mentions.delete', new Event());
}