function SqlContentEntityStorage::onFieldDefinitionDelete

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::onFieldDefinitionDelete()
  2. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::onFieldDefinitionDelete()
  3. 11.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::onFieldDefinitionDelete()

Overrides ContentEntityStorageBase::onFieldDefinitionDelete

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 1626

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition) {
    $table_mapping = $this->getTableMapping();
    $storage_definition = $field_definition->getFieldStorageDefinition();
    // Mark field data as deleted.
    if ($table_mapping->requiresDedicatedTableStorage($storage_definition)) {
        $table_name = $table_mapping->getDedicatedDataTableName($storage_definition);
        $revision_name = $table_mapping->getDedicatedRevisionTableName($storage_definition);
        $this->database
            ->update($table_name)
            ->fields([
            'deleted' => 1,
        ])
            ->condition('bundle', $field_definition->getTargetBundle())
            ->execute();
        if ($this->entityType
            ->isRevisionable()) {
            $this->database
                ->update($revision_name)
                ->fields([
                'deleted' => 1,
            ])
                ->condition('bundle', $field_definition->getTargetBundle())
                ->execute();
        }
    }
}

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