EntityTypeEventSubscriberTrait.php in Drupal 9
File
core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php
View source
<?php
namespace Drupal\Core\Entity;
trait EntityTypeEventSubscriberTrait {
public static function getEntityTypeEvents() {
$event = [
'onEntityTypeEvent',
100,
];
$events[EntityTypeEvents::CREATE][] = $event;
$events[EntityTypeEvents::UPDATE][] = $event;
$events[EntityTypeEvents::DELETE][] = $event;
return $events;
}
public function onEntityTypeEvent(EntityTypeEvent $event, $event_name) {
switch ($event_name) {
case EntityTypeEvents::CREATE:
$this
->onEntityTypeCreate($event
->getEntityType());
break;
case EntityTypeEvents::UPDATE:
$this
->onEntityTypeUpdate($event
->getEntityType(), $event
->getOriginal());
break;
case EntityTypeEvents::DELETE:
$this
->onEntityTypeDelete($event
->getEntityType());
break;
}
}
public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
}
public function onFieldableEntityTypeCreate(EntityTypeInterface $entity_type, array $field_storage_definitions) {
}
public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
}
public function onFieldableEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original, array $field_storage_definitions, array $original_field_storage_definitions, array &$sandbox = NULL) {
}
public function onEntityTypeDelete(EntityTypeInterface $entity_type) {
}
}