Article.php 3.0 KB

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