W3cubDocs

/Drupal 8

protected function 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 1561

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();
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorage.php/function/SqlContentEntityStorage::purgeFieldItems/8.1.x