Drupal Answers Asked on November 23, 2021
I have tried to create a hook that deletes an entity of type notification when the entity of type deadline is deleted, but the hook never gets called. Entities of type notification have one referenced entity of type deadline.
I have tried to clear the cache several times but without any luck. Am I missing something?
/**
* Implements hook_entity_predelete().
*
*/
function dib_notifications_entity_predelete(EntityInterface $entity) {
if ($entity->bundle() == 'deadline') {
$array = Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties
(['type' => 'notification',
'title' => $entity->label()
]);
$notification=reset($array);
$notification->delete();
}
}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP