function entityqueue_smartqueue_entity_delete in Entityqueue 8
Implements hook_entity_delete().
File
- modules/
entityqueue_smartqueue/ entityqueue_smartqueue.module, line 110 - Provides automated subqueues for each entity of a given entity type.
Code
function entityqueue_smartqueue_entity_delete(EntityInterface $entity) {
$queues = _entityqueue_smartqueue_get_queues($entity
->getEntityTypeId());
foreach ($queues as $queue) {
// Check if the entity that got deleted is of the relevant bundle.
if (!in_array($entity
->bundle(), $queue
->getHandlerConfiguration()['bundles'], TRUE)) {
continue;
}
if ($subqueue = EntitySubqueue::load($queue
->id() . '__' . $entity
->id())) {
$subqueue
->delete();
}
}
}