public function SqlContentEntityStorage::onFieldStorageDefinitionDelete in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::onFieldStorageDefinitionDelete()
- 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::onFieldStorageDefinitionDelete()
Reacts to the deletion of a field storage definition.
Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The field being deleted.
Overrides ContentEntityStorageBase::onFieldStorageDefinitionDelete
File
- core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorage.php, line 1548
Class
- SqlContentEntityStorage
- A content entity database storage implementation.
Namespace
Drupal\Core\Entity\SqlCode
public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition) {
$table_mapping = $this
->getTableMapping();
if ($table_mapping
->requiresDedicatedTableStorage($storage_definition)) {
// Mark all data associated with the field for deletion.
$table = $table_mapping
->getDedicatedDataTableName($storage_definition);
$revision_table = $table_mapping
->getDedicatedRevisionTableName($storage_definition);
$this->database
->update($table)
->fields([
'deleted' => 1,
])
->execute();
if ($this->entityType
->isRevisionable()) {
$this->database
->update($revision_table)
->fields([
'deleted' => 1,
])
->execute();
}
}
// Update the field schema.
$this
->wrapSchemaException(function () use ($storage_definition) {
$this
->getStorageSchema()
->onFieldStorageDefinitionDelete($storage_definition);
unset($this->fieldStorageDefinitions[$storage_definition
->getName()]);
$this->tableMapping = NULL;
});
}