Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Core\Entity;
|
Chris@0
|
4
|
Chris@0
|
5 /**
|
Chris@0
|
6 * Provides methods for an entity to support revisions.
|
Chris@16
|
7 *
|
Chris@16
|
8 * Classes implementing this interface do not necessarily support revisions.
|
Chris@16
|
9 *
|
Chris@16
|
10 * To detect whether an entity type supports revisions, call
|
Chris@16
|
11 * EntityTypeInterface::isRevisionable().
|
Chris@16
|
12 *
|
Chris@16
|
13 * Many entity interfaces are composed of numerous other interfaces such as this
|
Chris@16
|
14 * one, which allow implementations to pick and choose which features to.
|
Chris@16
|
15 * support through stub implementations of various interface methods. This means
|
Chris@16
|
16 * that even if an entity class implements RevisionableInterface, it might only
|
Chris@16
|
17 * have a stub implementation and not a functional one.
|
Chris@16
|
18 *
|
Chris@16
|
19 * @see \Drupal\Core\Entity\EntityTypeInterface::isRevisionable()
|
Chris@16
|
20 * @see https://www.drupal.org/docs/8/api/entity-api/structure-of-an-entity-annotation
|
Chris@16
|
21 * @see https://www.drupal.org/docs/8/api/entity-api/making-an-entity-revisionable
|
Chris@0
|
22 */
|
Chris@18
|
23 interface RevisionableInterface extends EntityInterface {
|
Chris@0
|
24
|
Chris@0
|
25 /**
|
Chris@0
|
26 * Determines whether a new revision should be created on save.
|
Chris@0
|
27 *
|
Chris@0
|
28 * @return bool
|
Chris@0
|
29 * TRUE if a new revision should be created.
|
Chris@0
|
30 *
|
Chris@0
|
31 * @see \Drupal\Core\Entity\EntityInterface::setNewRevision()
|
Chris@0
|
32 */
|
Chris@0
|
33 public function isNewRevision();
|
Chris@0
|
34
|
Chris@0
|
35 /**
|
Chris@0
|
36 * Enforces an entity to be saved as a new revision.
|
Chris@0
|
37 *
|
Chris@0
|
38 * @param bool $value
|
Chris@0
|
39 * (optional) Whether a new revision should be saved.
|
Chris@0
|
40 *
|
Chris@0
|
41 * @throws \LogicException
|
Chris@0
|
42 * Thrown if the entity does not support revisions.
|
Chris@0
|
43 *
|
Chris@0
|
44 * @see \Drupal\Core\Entity\EntityInterface::isNewRevision()
|
Chris@0
|
45 */
|
Chris@0
|
46 public function setNewRevision($value = TRUE);
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * Gets the revision identifier of the entity.
|
Chris@0
|
50 *
|
Chris@0
|
51 * @return
|
Chris@0
|
52 * The revision identifier of the entity, or NULL if the entity does not
|
Chris@0
|
53 * have a revision identifier.
|
Chris@0
|
54 */
|
Chris@0
|
55 public function getRevisionId();
|
Chris@0
|
56
|
Chris@0
|
57 /**
|
Chris@17
|
58 * Gets the loaded Revision ID of the entity.
|
Chris@17
|
59 *
|
Chris@17
|
60 * @return int
|
Chris@17
|
61 * The loaded Revision identifier of the entity, or NULL if the entity
|
Chris@17
|
62 * does not have a revision identifier.
|
Chris@17
|
63 */
|
Chris@17
|
64 public function getLoadedRevisionId();
|
Chris@17
|
65
|
Chris@17
|
66 /**
|
Chris@17
|
67 * Updates the loaded Revision ID with the revision ID.
|
Chris@17
|
68 *
|
Chris@17
|
69 * This method should not be used, it could unintentionally cause the original
|
Chris@17
|
70 * revision ID property value to be lost.
|
Chris@17
|
71 *
|
Chris@17
|
72 * @internal
|
Chris@17
|
73 *
|
Chris@17
|
74 * @return $this
|
Chris@17
|
75 */
|
Chris@17
|
76 public function updateLoadedRevisionId();
|
Chris@17
|
77
|
Chris@17
|
78 /**
|
Chris@0
|
79 * Checks if this entity is the default revision.
|
Chris@0
|
80 *
|
Chris@0
|
81 * @param bool $new_value
|
Chris@0
|
82 * (optional) A Boolean to (re)set the isDefaultRevision flag.
|
Chris@0
|
83 *
|
Chris@0
|
84 * @return bool
|
Chris@0
|
85 * TRUE if the entity is the default revision, FALSE otherwise. If
|
Chris@0
|
86 * $new_value was passed, the previous value is returned.
|
Chris@0
|
87 */
|
Chris@0
|
88 public function isDefaultRevision($new_value = NULL);
|
Chris@0
|
89
|
Chris@0
|
90 /**
|
Chris@14
|
91 * Checks whether the entity object was a default revision when it was saved.
|
Chris@14
|
92 *
|
Chris@14
|
93 * @return bool
|
Chris@14
|
94 * TRUE if the entity object was a revision, FALSE otherwise.
|
Chris@14
|
95 */
|
Chris@14
|
96 public function wasDefaultRevision();
|
Chris@14
|
97
|
Chris@14
|
98 /**
|
Chris@14
|
99 * Checks if this entity is the latest revision.
|
Chris@14
|
100 *
|
Chris@14
|
101 * @return bool
|
Chris@14
|
102 * TRUE if the entity is the latest revision, FALSE otherwise.
|
Chris@14
|
103 */
|
Chris@14
|
104 public function isLatestRevision();
|
Chris@14
|
105
|
Chris@14
|
106 /**
|
Chris@0
|
107 * Acts on a revision before it gets saved.
|
Chris@0
|
108 *
|
Chris@0
|
109 * @param EntityStorageInterface $storage
|
Chris@0
|
110 * The entity storage object.
|
Chris@0
|
111 * @param \stdClass $record
|
Chris@0
|
112 * The revision object.
|
Chris@0
|
113 */
|
Chris@0
|
114 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record);
|
Chris@0
|
115
|
Chris@0
|
116 }
|