Article.php 1.0 KB

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