W3cubDocs

/Drupal 8

public function ContentEntityStorageBase::deleteRevision

public ContentEntityStorageBase::deleteRevision($revision_id)

Delete a specific entity revision.

A revision can only be deleted if it's not the currently active one.

Parameters

int $revision_id: The revision id.

Overrides EntityStorageInterface::deleteRevision

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 334

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

public function deleteRevision($revision_id) {
  /** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
  if ($revision = $this->loadRevision($revision_id)) {
    // Prevent deletion if this is the default revision.
    if ($revision->isDefaultRevision()) {
      throw new EntityStorageException('Default revision can not be deleted');
    }
    $this->invokeFieldMethod('deleteRevision', $revision);
    $this->doDeleteRevisionFieldItems($revision);
    $this->invokeHook('revision_delete', $revision);
  }
}

© 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!ContentEntityStorageBase.php/function/ContentEntityStorageBase::deleteRevision/8.1.x