You are here

public function MultiversionMigration::emptyOldStorage in Multiversion 8

Usage example:

// For some specific content types, we are still able to use
// a `purge` or `delete` function.
if (in_array($this
  ->getEntityTypeId(), [
  'replication_log',
])) {
  $original_storage = $storage
    ->getOriginalStorage();
  $entities = $original_storage
    ->loadMultiple();
  $this
    ->purge($entities);
}

Overrides MultiversionMigrationInterface::emptyOldStorage

File

src/MultiversionMigration.php, line 121

Class

MultiversionMigration

Namespace

Drupal\multiversion

Code

public function emptyOldStorage(EntityStorageInterface $storage) {
  if ($storage instanceof ContentEntityStorageInterface) {
    $storage
      ->truncate();
  }
  elseif ($storage instanceof FileStorageInterface) {

    // Do not delete file entity from the storage as it deletes physical
    // file - just truncate file managed database table.
    $this->connection
      ->truncate('file_managed')
      ->execute();
  }
  else {
    $entities = $storage
      ->loadMultiple();
    $storage
      ->delete($entities);
  }
  return $this;
}