function EntityTypeEventSubscriberTrait::onEntityTypeEvent

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php \Drupal\Core\Entity\EntityTypeEventSubscriberTrait::onEntityTypeEvent()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php \Drupal\Core\Entity\EntityTypeEventSubscriberTrait::onEntityTypeEvent()
  3. 10 core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php \Drupal\Core\Entity\EntityTypeEventSubscriberTrait::onEntityTypeEvent()

Listener method for any entity type definition event.

Parameters

\Drupal\Core\Entity\EntityTypeEvent $event: The field storage definition event object.

string $event_name: The event name.

File

core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php, line 40

Class

EntityTypeEventSubscriberTrait
Helper methods for EntityTypeListenerInterface.

Namespace

Drupal\Core\Entity

Code

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;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.