annotate core/lib/Drupal/Core/Entity/RevisionableInterface.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
rev   line source
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@0 7 *
Chris@0 8 * Classes implementing this interface do not necessarily support revisions.
Chris@0 9 *
Chris@0 10 * To detect whether an entity type supports revisions, call
Chris@0 11 * EntityTypeInterface::isRevisionable().
Chris@0 12 *
Chris@0 13 * Many entity interfaces are composed of numerous other interfaces such as this
Chris@0 14 * one, which allow implementations to pick and choose which features to.
Chris@0 15 * support through stub implementations of various interface methods. This means
Chris@0 16 * that even if an entity class implements RevisionableInterface, it might only
Chris@0 17 * have a stub implementation and not a functional one.
Chris@0 18 *
Chris@0 19 * @see \Drupal\Core\Entity\EntityTypeInterface::isRevisionable()
Chris@0 20 * @see https://www.drupal.org/docs/8/api/entity-api/structure-of-an-entity-annotation
Chris@0 21 * @see https://www.drupal.org/docs/8/api/entity-api/making-an-entity-revisionable
Chris@0 22 */
Chris@0 23 interface RevisionableInterface {
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@0 58 * Checks if this entity is the default revision.
Chris@0 59 *
Chris@0 60 * @param bool $new_value
Chris@0 61 * (optional) A Boolean to (re)set the isDefaultRevision flag.
Chris@0 62 *
Chris@0 63 * @return bool
Chris@0 64 * TRUE if the entity is the default revision, FALSE otherwise. If
Chris@0 65 * $new_value was passed, the previous value is returned.
Chris@0 66 */
Chris@0 67 public function isDefaultRevision($new_value = NULL);
Chris@0 68
Chris@0 69 /**
Chris@0 70 * Checks whether the entity object was a default revision when it was saved.
Chris@0 71 *
Chris@0 72 * @return bool
Chris@0 73 * TRUE if the entity object was a revision, FALSE otherwise.
Chris@0 74 */
Chris@0 75 public function wasDefaultRevision();
Chris@0 76
Chris@0 77 /**
Chris@0 78 * Checks if this entity is the latest revision.
Chris@0 79 *
Chris@0 80 * @return bool
Chris@0 81 * TRUE if the entity is the latest revision, FALSE otherwise.
Chris@0 82 */
Chris@0 83 public function isLatestRevision();
Chris@0 84
Chris@0 85 /**
Chris@0 86 * Acts on a revision before it gets saved.
Chris@0 87 *
Chris@0 88 * @param EntityStorageInterface $storage
Chris@0 89 * The entity storage object.
Chris@0 90 * @param \stdClass $record
Chris@0 91 * The revision object.
Chris@0 92 */
Chris@0 93 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record);
Chris@0 94
Chris@0 95 }