W3cubDocs

/Drupal 8

protected function SqlContentEntityStorage::deleteRevisionFromDedicatedTables

protected SqlContentEntityStorage::deleteRevisionFromDedicatedTables(ContentEntityInterface $entity)

Deletes values of fields in dedicated tables for all revisions.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity. It must have a revision ID.

File

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

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

protected function deleteRevisionFromDedicatedTables(ContentEntityInterface $entity) {
  $vid = $entity->getRevisionId();
  if (isset($vid)) {
    $table_mapping = $this->getTableMapping();
    foreach ($this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle()) as $field_definition) {
      $storage_definition = $field_definition->getFieldStorageDefinition();
      if (!$table_mapping->requiresDedicatedTableStorage($storage_definition)) {
        continue;
      }
      $revision_name = $table_mapping->getDedicatedRevisionTableName($storage_definition);
      $this->database->delete($revision_name)
        ->condition('entity_id', $entity->id())
        ->condition('revision_id', $vid)
        ->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::deleteRevisionFromDedicatedTables/8.1.x