RevisionableStorageInterface.php 1.85 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

namespace Drupal\Core\Entity;

/**
 * A storage that supports revisionable entity types.
 */
interface RevisionableStorageInterface {

10 11 12 13 14 15 16 17 18 19 20 21 22 23
  /**
   * Creates a new revision starting off from the specified entity object.
   *
   * @param \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface $entity
   *   The revisionable entity object being modified.
   * @param bool $default
   *   (optional) Whether the new revision should be marked as default. Defaults
   *   to TRUE.
   *
   * @return \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\RevisionableInterface
   *   A new entity revision object.
   */
  public function createRevision(RevisionableInterface $entity, $default = TRUE);

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  /**
   * Loads a specific entity revision.
   *
   * @param int $revision_id
   *   The revision ID.
   *
   * @return \Drupal\Core\Entity\EntityInterface|null
   *   The specified entity revision or NULL if not found.
   */
  public function loadRevision($revision_id);

  /**
   * Loads multiple entity revisions.
   *
   * @param array $revision_ids
   *   An array of revision IDs to load.
   *
   * @return \Drupal\Core\Entity\EntityInterface[]
   *   An array of entity revisions keyed by their revision ID, or an empty
   *   array if none found.
   */
  public function loadMultipleRevisions(array $revision_ids);

  /**
   * Deletes a specific entity revision.
   *
   * A revision can only be deleted if it's not the currently active one.
   *
   * @param int $revision_id
   *   The revision ID.
   */
  public function deleteRevision($revision_id);

57 58 59 60 61 62 63 64 65 66 67
  /**
   * Returns the latest revision identifier for an entity.
   *
   * @param int|string $entity_id
   *   The entity identifier.
   *
   * @return int|string|null
   *   The latest revision identifier or NULL if no revision could be found.
   */
  public function getLatestRevisionId($entity_id);

68
}