EntityChangedInterface.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Drupal\Core\Entity;
  3. /**
  4. * Defines an interface for entity change timestamp tracking.
  5. *
  6. * This data may be useful for more precise cache invalidation (especially
  7. * on the client side) and concurrent editing locking.
  8. *
  9. * The entity system automatically adds in the 'EntityChanged' constraint for
  10. * entity types implementing this interface in order to disallow concurrent
  11. * editing.
  12. *
  13. * @see Drupal\Core\Entity\Plugin\Validation\Constraint\EntityChangedConstraint
  14. */
  15. interface EntityChangedInterface {
  16. /**
  17. * Gets the timestamp of the last entity change for the current translation.
  18. *
  19. * @return int
  20. * The timestamp of the last entity save operation.
  21. */
  22. public function getChangedTime();
  23. /**
  24. * Sets the timestamp of the last entity change for the current translation.
  25. *
  26. * @param int $timestamp
  27. * The timestamp of the last entity save operation.
  28. *
  29. * @return $this
  30. */
  31. public function setChangedTime($timestamp);
  32. /**
  33. * Gets the timestamp of the last entity change across all translations.
  34. *
  35. * This method will return the highest timestamp across all translations. To
  36. * check that no translation is older than in another version of the entity
  37. * (e.g. to avoid overwriting newer translations with old data), compare each
  38. * translation to the other version individually.
  39. *
  40. * @return int
  41. * The timestamp of the last entity save operation across all
  42. * translations.
  43. */
  44. public function getChangedTimeAcrossTranslations();
  45. }