SqlContentEntityStorage::purgeFieldItems

protected SqlContentEntityStorage::purgeFieldItems(ContentEntityInterface $entity, FieldDefinitionInterface $field_definition)

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 1576

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)
    ->condition('deleted', 1)
    ->execute();
  if ($this->entityType->isRevisionable()) {
    $this->database->delete($revision_name)
      ->condition('revision_id', $revision_id)
      ->condition('deleted', 1)
      ->execute();
  }
}
doc_Drupal
2016-10-29 09:43:28
Comments
Leave a Comment

Please login to continue.