Article.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace Translatable\Fixture;
  3. use Gedmo\Translatable\Translatable;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity
  8. */
  9. class Article implements Translatable
  10. {
  11. /** @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer") */
  12. private $id;
  13. /**
  14. * @Gedmo\Translatable
  15. * @ORM\Column(name="title", type="string", length=128)
  16. */
  17. private $title;
  18. /**
  19. * @Gedmo\Translatable
  20. * @ORM\Column(name="content", type="text", nullable=true)
  21. */
  22. private $content;
  23. /**
  24. * @Gedmo\Translatable
  25. * @ORM\Column(name="views", type="integer", nullable=true)
  26. */
  27. private $views;
  28. /**
  29. * Used locale to override Translation listener`s locale
  30. * @Gedmo\Locale
  31. */
  32. private $locale;
  33. /**
  34. * @ORM\OneToMany(targetEntity="Comment", mappedBy="article")
  35. */
  36. private $comments;
  37. public function getId()
  38. {
  39. return $this->id;
  40. }
  41. public function addComment(Comment $comment)
  42. {
  43. $comment->setArticle($this);
  44. $this->comments[] = $comment;
  45. }
  46. public function getComments()
  47. {
  48. return $this->comments;
  49. }
  50. public function setTitle($title)
  51. {
  52. $this->title = $title;
  53. }
  54. public function getTitle()
  55. {
  56. return $this->title;
  57. }
  58. public function setContent($content)
  59. {
  60. $this->content = $content;
  61. }
  62. public function getContent()
  63. {
  64. return $this->content;
  65. }
  66. public function setTranslatableLocale($locale)
  67. {
  68. $this->locale = $locale;
  69. }
  70. public function setViews ($views)
  71. {
  72. $this->views = $views;
  73. }
  74. public function getViews ()
  75. {
  76. return $this->views;
  77. }
  78. }