RevisionableInterface.php 2.0 KB

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