Article.php 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Tree\Fixture;
  3. /**
  4. * @Entity
  5. */
  6. class Article
  7. {
  8. /**
  9. * @Id
  10. * @GeneratedValue
  11. * @Column(type="integer")
  12. */
  13. private $id;
  14. /**
  15. * @Column(name="title", type="string", length=128)
  16. */
  17. private $title;
  18. /**
  19. * @OneToMany(targetEntity="Comment", mappedBy="article")
  20. */
  21. private $comments;
  22. /**
  23. * @ManyToOne(targetEntity="Category", inversedBy="articles")
  24. */
  25. private $category;
  26. public function getId()
  27. {
  28. return $this->id;
  29. }
  30. public function setCategory($category)
  31. {
  32. $this->category = $category;
  33. }
  34. public function addComment(Comment $comment)
  35. {
  36. $comment->setArticle($this);
  37. $this->comments[] = $comment;
  38. }
  39. public function getComments()
  40. {
  41. return $this->comments;
  42. }
  43. public function setTitle($title)
  44. {
  45. $this->title = $title;
  46. }
  47. public function getTitle()
  48. {
  49. return $this->title;
  50. }
  51. }