Version 1
[yaffs-website] / web / core / lib / Drupal / Core / Entity / RevisionableInterface.php
1 <?php
2
3 namespace Drupal\Core\Entity;
4
5 /**
6  * Provides methods for an entity to support revisions.
7  */
8 interface RevisionableInterface {
9
10   /**
11    * Determines whether a new revision should be created on save.
12    *
13    * @return bool
14    *   TRUE if a new revision should be created.
15    *
16    * @see \Drupal\Core\Entity\EntityInterface::setNewRevision()
17    */
18   public function isNewRevision();
19
20   /**
21    * Enforces an entity to be saved as a new revision.
22    *
23    * @param bool $value
24    *   (optional) Whether a new revision should be saved.
25    *
26    * @throws \LogicException
27    *   Thrown if the entity does not support revisions.
28    *
29    * @see \Drupal\Core\Entity\EntityInterface::isNewRevision()
30    */
31   public function setNewRevision($value = TRUE);
32
33   /**
34    * Gets the revision identifier of the entity.
35    *
36    * @return
37    *   The revision identifier of the entity, or NULL if the entity does not
38    *   have a revision identifier.
39    */
40   public function getRevisionId();
41
42   /**
43    * Checks if this entity is the default revision.
44    *
45    * @param bool $new_value
46    *   (optional) A Boolean to (re)set the isDefaultRevision flag.
47    *
48    * @return bool
49    *   TRUE if the entity is the default revision, FALSE otherwise. If
50    *   $new_value was passed, the previous value is returned.
51    */
52   public function isDefaultRevision($new_value = NULL);
53
54   /**
55    * Acts on a revision before it gets saved.
56    *
57    * @param EntityStorageInterface $storage
58    *   The entity storage object.
59    * @param \stdClass $record
60    *   The revision object.
61    */
62   public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record);
63
64 }