function image_hotspots_image_style_delete in Image Hotspots 8
Implements hook_ENTITY_TYPE_delete().
If image style 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 65 - Main functions of module.
Code
function image_hotspots_image_style_delete(EntityInterface $entity) {
$style_name = $entity
->id();
$hids = Drupal::entityQuery('image_hotspot')
->condition('image_style', $style_name, '=')
->execute();
$queue = Drupal::queue('cron_image_hotspots_deletion', TRUE);
$queue
->createQueue();
foreach ($hids as $hid) {
$queue
->createItem([
'hid' => $hid,
]);
}
}