You are here

public function EntityTestDefinitionSubscriber::onEntityTypeDelete in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_test/src/EntityTestDefinitionSubscriber.php \Drupal\entity_test\EntityTestDefinitionSubscriber::onEntityTypeDelete()
  2. 9 core/modules/system/tests/modules/entity_test/src/EntityTestDefinitionSubscriber.php \Drupal\entity_test\EntityTestDefinitionSubscriber::onEntityTypeDelete()

Reacts to the deletion of the entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type being deleted.

Overrides EntityTypeEventSubscriberTrait::onEntityTypeDelete

File

core/modules/system/tests/modules/entity_test/src/EntityTestDefinitionSubscriber.php, line 141

Class

EntityTestDefinitionSubscriber
Test entity type and field storage definition event subscriber.

Namespace

Drupal\entity_test

Code

public function onEntityTypeDelete(EntityTypeInterface $entity_type) {
  if (!$this->entityLastInstalledSchemaRepository
    ->getLastInstalledDefinition($entity_type
    ->id())) {
    $this
      ->storeDefinitionUpdate(EntityTypeEvents::DELETE);
  }
  $this
    ->storeEvent(EntityTypeEvents::DELETE);

  // Retrieve the live entity type definition in order to warm the static
  // cache and then delete the new entity type definition, so we can test that
  // the cache doesn't get stale after the event has fired.
  if ($this->updateLiveDefinitions) {
    $this->entityTypeManager
      ->getDefinition($entity_type
      ->id());
    $this->state
      ->set('entity_test_rev.entity_type', '');
  }
}