TimestampableDocument.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Gedmo\Timestampable\Traits;
  3. /**
  4. * Timestampable Trait, usable with PHP >= 5.4
  5. *
  6. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  7. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  8. */
  9. trait TimestampableDocument
  10. {
  11. /**
  12. * @Gedmo\Timestampable(on="create")
  13. * @ODM\Date
  14. */
  15. private $createdAt;
  16. /**
  17. * @Gedmo\Timestampable(on="update")
  18. * @ODM\Date
  19. */
  20. private $updatedAt;
  21. /**
  22. * Sets createdAt.
  23. *
  24. * @param Datetime $createdAt
  25. * @return $this
  26. */
  27. public function setCreatedAt(\DateTime $createdAt)
  28. {
  29. $this->createdAt = $createdAt;
  30. return $this;
  31. }
  32. /**
  33. * Returns createdAt.
  34. *
  35. * @return DateTime
  36. */
  37. public function getCreatedAt()
  38. {
  39. return $this->createdAt;
  40. }
  41. /**
  42. * Sets updatedAt.
  43. *
  44. * @param DateTime $updatedAt
  45. * @return $this
  46. */
  47. public function setUpdatedAt(\DateTime $updatedAt)
  48. {
  49. $this->updatedAt = $updatedAt;
  50. return $this;
  51. }
  52. /**
  53. * Returns updatedAt.
  54. *
  55. * @return Datetime
  56. */
  57. public function getUpdatedAt()
  58. {
  59. return $this->updatedAt;
  60. }
  61. }