You are here

function image_hotspots_file_delete in Image Hotspots 8

Implements hook_ENTITY_TYPE_delete().

If file was deleted we need to delete all hotspots that referenced on it. So insert all of them in on cron run deletion queue.

File

./image_hotspots.module, line 47
Main functions of module.

Code

function image_hotspots_file_delete(EntityInterface $entity) {
  $fid = $entity
    ->id();
  $hids = Drupal::entityQuery('image_hotspot')
    ->condition('fid', $fid, '=')
    ->execute();
  $queue = Drupal::queue('cron_image_hotspots_deletion', TRUE);
  $queue
    ->createQueue();
  foreach ($hids as $hid) {
    $queue
      ->createItem([
      'hid' => $hid,
    ]);
  }
}