Article.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. namespace Timestampable\Fixture;
  3. use Gedmo\Timestampable\Timestampable;
  4. /**
  5. * @Entity
  6. */
  7. class Article implements Timestampable
  8. {
  9. /** @Id @GeneratedValue @Column(type="integer") */
  10. private $id;
  11. /**
  12. * @Column(name="title", type="string", length=128)
  13. */
  14. private $title;
  15. /**
  16. * @OneToMany(targetEntity="Timestampable\Fixture\Comment", mappedBy="article")
  17. */
  18. private $comments;
  19. /**
  20. * @var datetime $created
  21. *
  22. * @gedmo:Timestampable(on="create")
  23. * @Column(name="created", type="date")
  24. */
  25. private $created;
  26. /**
  27. * @var datetime $updated
  28. *
  29. * @Column(name="updated", type="datetime")
  30. * @gedmo:Timestampable
  31. */
  32. private $updated;
  33. /**
  34. * @var datetime $published
  35. *
  36. * @Column(name="published", type="datetime", nullable=true)
  37. * @gedmo:Timestampable(on="change", field="type.title", value="Published")
  38. */
  39. private $published;
  40. /**
  41. * @ManyToOne(targetEntity="Type", inversedBy="articles")
  42. */
  43. private $type;
  44. public function setType($type)
  45. {
  46. $this->type = $type;
  47. }
  48. public function getId()
  49. {
  50. return $this->id;
  51. }
  52. public function setTitle($title)
  53. {
  54. $this->title = $title;
  55. }
  56. public function getTitle()
  57. {
  58. return $this->title;
  59. }
  60. public function addComment(Comment $comment)
  61. {
  62. $comment->setArticle($this);
  63. $this->comments[] = $comment;
  64. }
  65. public function getComments()
  66. {
  67. return $this->comments;
  68. }
  69. /**
  70. * Get created
  71. *
  72. * @return datetime $created
  73. */
  74. public function getCreated()
  75. {
  76. return $this->created;
  77. }
  78. public function setCreated(\DateTime $created)
  79. {
  80. $this->created = $created;
  81. }
  82. public function getPublished()
  83. {
  84. return $this->published;
  85. }
  86. public function setPublished(\DateTime $published)
  87. {
  88. $this->published = $published;
  89. }
  90. /**
  91. * Get updated
  92. *
  93. * @return datetime $updated
  94. */
  95. public function getUpdated()
  96. {
  97. return $this->updated;
  98. }
  99. public function setUpdated(\DateTime $updated)
  100. {
  101. $this->updated = $updated;
  102. }
  103. }