entity_events
1,034 sites
Security covered
Module which dispatches events for entity create, update, delete.
Provides abstract classes for event listeners for you to extend in your own modules to 'do stuff' on entity operations. Can use as a replacement for hook_entity_[update/insert/delete] from within your module file.
Abstract classes:
EntityEventSubscriber
EntityEventInsertSubscriber
EntityEventUpdateSubscriber
EntityEventDeleteSubscriber
EntityEventPredeleteSubscriber
EntityEventPresaveSubscriber
Extend these classes with your own module subscribers.
Example implementation
namespace Drupal\mymodule\EventSubscriber;
use Drupal\entity_events\Event\EntityEvent;
use Drupal\entity_events\EventSubscriber\EntityEventInsertSubscriber;
class MyModuleSubscriber extends EntityEventInsertSubscriber {
public function onEntityInsert(EntityEvent $event) {
// Implement your logic here.
}
}
Remember to add event listeners to your services.yml.file
e.g.
services:
mymodule.subscriber:
class: Drupal\mymodule\EventSubscriber\MyModuleSubscriber
tags:
- {name: event_subscriber}Drupal Core since 11.1 supports hooks in classes out of the box. See change record here https://www.drupal.org/node/3442349 . It is strongly recommended to use the core feature instead of this module.
Similar modules: