SoftDeleteableEntity.php 981 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Gedmo\SoftDeleteable\Traits;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * SoftDeletable Trait, usable with PHP >= 5.4
  6. *
  7. * @author Wesley van Opdorp <wesley.van.opdorp@freshheads.com>
  8. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  9. */
  10. trait SoftDeleteableEntity
  11. {
  12. /**
  13. * @var \DateTime
  14. * @ORM\Column(type="datetime", nullable=true)
  15. */
  16. protected $deletedAt;
  17. /**
  18. * Sets deletedAt.
  19. *
  20. * @param \DateTime|null $deletedAt
  21. *
  22. * @return $this
  23. */
  24. public function setDeletedAt(\DateTime $deletedAt = null)
  25. {
  26. $this->deletedAt = $deletedAt;
  27. return $this;
  28. }
  29. /**
  30. * Returns deletedAt.
  31. *
  32. * @return \DateTime
  33. */
  34. public function getDeletedAt()
  35. {
  36. return $this->deletedAt;
  37. }
  38. /**
  39. * Is deleted?
  40. *
  41. * @return bool
  42. */
  43. public function isDeleted()
  44. {
  45. return null !== $this->deletedAt;
  46. }
  47. }