You are here

protected function SqlContentEntityStorage::purgeFieldItems in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::purgeFieldItems()

Removes field items from storage per entity during purge.

Parameters

ContentEntityInterface $entity: The entity revision, whose values are being purged.

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field whose values are bing purged.

Overrides ContentEntityStorageBase::purgeFieldItems

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 1562
Contains \Drupal\Core\Entity\Sql\SqlContentEntityStorage.

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

protected function purgeFieldItems(ContentEntityInterface $entity, FieldDefinitionInterface $field_definition) {
  $storage_definition = $field_definition
    ->getFieldStorageDefinition();
  $is_deleted = $this
    ->storageDefinitionIsDeleted($storage_definition);
  $table_mapping = $this
    ->getTableMapping();
  $table_name = $table_mapping
    ->getDedicatedDataTableName($storage_definition, $is_deleted);
  $revision_name = $table_mapping
    ->getDedicatedRevisionTableName($storage_definition, $is_deleted);
  $revision_id = $this->entityType
    ->isRevisionable() ? $entity
    ->getRevisionId() : $entity
    ->id();
  $this->database
    ->delete($table_name)
    ->condition('revision_id', $revision_id)
    ->execute();
  if ($this->entityType
    ->isRevisionable()) {
    $this->database
      ->delete($revision_name)
      ->condition('revision_id', $revision_id)
      ->execute();
  }
}