3 namespace Drupal\Core\Entity;
6 * Provides methods for an entity to support revisions.
8 * Classes implementing this interface do not necessarily support revisions.
10 * To detect whether an entity type supports revisions, call
11 * EntityTypeInterface::isRevisionable().
13 * Many entity interfaces are composed of numerous other interfaces such as this
14 * one, which allow implementations to pick and choose which features to.
15 * support through stub implementations of various interface methods. This means
16 * that even if an entity class implements RevisionableInterface, it might only
17 * have a stub implementation and not a functional one.
19 * @see \Drupal\Core\Entity\EntityTypeInterface::isRevisionable()
20 * @see https://www.drupal.org/docs/8/api/entity-api/structure-of-an-entity-annotation
21 * @see https://www.drupal.org/docs/8/api/entity-api/making-an-entity-revisionable
23 interface RevisionableInterface {
26 * Determines whether a new revision should be created on save.
29 * TRUE if a new revision should be created.
31 * @see \Drupal\Core\Entity\EntityInterface::setNewRevision()
33 public function isNewRevision();
36 * Enforces an entity to be saved as a new revision.
39 * (optional) Whether a new revision should be saved.
41 * @throws \LogicException
42 * Thrown if the entity does not support revisions.
44 * @see \Drupal\Core\Entity\EntityInterface::isNewRevision()
46 public function setNewRevision($value = TRUE);
49 * Gets the revision identifier of the entity.
52 * The revision identifier of the entity, or NULL if the entity does not
53 * have a revision identifier.
55 public function getRevisionId();
58 * Gets the loaded Revision ID of the entity.
61 * The loaded Revision identifier of the entity, or NULL if the entity
62 * does not have a revision identifier.
64 public function getLoadedRevisionId();
67 * Updates the loaded Revision ID with the revision ID.
69 * This method should not be used, it could unintentionally cause the original
70 * revision ID property value to be lost.
76 public function updateLoadedRevisionId();
79 * Checks if this entity is the default revision.
81 * @param bool $new_value
82 * (optional) A Boolean to (re)set the isDefaultRevision flag.
85 * TRUE if the entity is the default revision, FALSE otherwise. If
86 * $new_value was passed, the previous value is returned.
88 public function isDefaultRevision($new_value = NULL);
91 * Checks whether the entity object was a default revision when it was saved.
94 * TRUE if the entity object was a revision, FALSE otherwise.
96 public function wasDefaultRevision();
99 * Checks if this entity is the latest revision.
102 * TRUE if the entity is the latest revision, FALSE otherwise.
104 public function isLatestRevision();
107 * Acts on a revision before it gets saved.
109 * @param EntityStorageInterface $storage
110 * The entity storage object.
111 * @param \stdClass $record
112 * The revision object.
114 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record);