function SqlContentEntityStorageSchema::onEntityTypeDelete

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeDelete()
  2. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeDelete()
  3. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeDelete()

Reacts to the deletion of the entity type.

Parameters

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

Overrides EntityTypeListenerInterface::onEntityTypeDelete

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 385

Class

SqlContentEntityStorageSchema
Defines a schema handler that supports revisionable, translatable entities.

Namespace

Drupal\Core\Entity\Sql

Code

public function onEntityTypeDelete(EntityTypeInterface $entity_type) {
  $this->checkEntityType($entity_type);
  $schema_handler = $this->database
    ->schema();
  // Delete entity and field tables.
  $table_names = $this->getTableNames($entity_type, $this->fieldStorageDefinitions, $this->getTableMapping($entity_type));
  foreach ($table_names as $table_name) {
    if ($schema_handler->tableExists($table_name)) {
      $schema_handler->dropTable($table_name);
    }
  }
  // Delete the field schema data.
  foreach ($this->fieldStorageDefinitions as $field_storage_definition) {
    $this->deleteFieldSchemaData($field_storage_definition);
  }
  // Delete the entity schema.
  $this->deleteEntitySchemaData($entity_type);
}

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