function SqlContentEntityStorageSchema::onEntityTypeUpdate
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeUpdate()
- 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeUpdate()
- 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::onEntityTypeUpdate()
Overrides EntityTypeListenerInterface::onEntityTypeUpdate
File
-
core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorageSchema.php, line 356
Class
- SqlContentEntityStorageSchema
- Defines a schema handler that supports revisionable, translatable entities.
Namespace
Drupal\Core\Entity\SqlCode
public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
$this->checkEntityType($entity_type);
$this->checkEntityType($original);
// If no schema changes are needed, we don't need to do anything.
if (!$this->requiresEntityStorageSchemaChanges($entity_type, $original)) {
return;
}
// If shared table schema changes are needed, we can't proceed.
if (!class_exists($original->getStorageClass()) || $this->hasSharedTableStructureChange($entity_type, $original)) {
throw new EntityStorageException('It is not possible to change the entity type schema outside of a batch context. Use EntityDefinitionUpdateManagerInterface::updateFieldableEntityType() instead.');
}
// Drop original indexes and unique keys.
$this->deleteEntitySchemaIndexes($this->loadEntitySchemaData($entity_type));
// Create new indexes and unique keys.
$entity_schema = $this->getEntitySchema($entity_type, TRUE);
$this->createEntitySchemaIndexes($entity_schema);
// Store the updated entity schema.
$this->saveEntitySchemaData($entity_type, $entity_schema);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.