TimestampableDocument.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * @package Gedmo.Timestampable.Traits
  8. * @subpackage TimestampableDocument
  9. * @link http://www.gediminasm.org
  10. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  11. */
  12. trait TimestampableDocument
  13. {
  14. /**
  15. * @Gedmo\Timestampable(on="create")
  16. * @ODM\Date
  17. */
  18. private $createdAt;
  19. /**
  20. * @Gedmo\Timestampable(on="update")
  21. * @ODM\Date
  22. */
  23. private $updatedAt;
  24. /**
  25. * Sets createdAt.
  26. *
  27. * @param Datetime $createdAt
  28. * @return $this
  29. */
  30. public function setCreatedAt(\DateTime $createdAt)
  31. {
  32. $this->createdAt = $createdAt;
  33. return $this;
  34. }
  35. /**
  36. * Returns createdAt.
  37. *
  38. * @return DateTime
  39. */
  40. public function getCreatedAt()
  41. {
  42. return $this->createdAt;
  43. }
  44. /**
  45. * Sets updatedAt.
  46. *
  47. * @param DateTime $updatedAt
  48. * @return $this
  49. */
  50. public function setUpdatedAt(\DateTime $updatedAt)
  51. {
  52. $this->updatedAt = $updatedAt;
  53. return $this;
  54. }
  55. /**
  56. * Returns updatedAt.
  57. *
  58. * @return Datetime
  59. */
  60. public function getUpdatedAt()
  61. {
  62. return $this->updatedAt;
  63. }
  64. }