So I'm trying to get an event subscriber working for EntityTypeEvents and I can't figure out why it's not firing.
This is a general outline of the code:
namespace Drupal\subscriber_class_module;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\Entity\EntityTypeEvents;
use Drupal\Core\Entity\EntityTypeEvent;
class SubscriberClassModuleSubscribesToEntityTypeEvents implements EventSubscriberInterface {
public function onCreate(EntityTypeEvent $event) {
//Do things on creation
}
public function onUpdate(EntityTypeEvent $event) {
//Do things on update
}
public function onDelete(EntityTypeEvent $event) {
//Do things on delete
}
static function getSubscribedEvents() {
$events = [];
$events[EntityTypeEvents::CREATE][] = array('onCreate', 100);
$events[EntityTypeEvents::UPDATE][] = array('onUpdate', 100);
$events[EntityTypeEvents::DELETE][] = array('onDelete', 100);
return $events;
}
}
Added class declaration and namespacing. I should note that the same class that I am using has no probablem firing on kernel events, I'm just wondering if there is something special about entity events.