TranslatableArticle.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace Sluggable\Fixture;
  3. use Gedmo\Sluggable\Sluggable;
  4. use Gedmo\Translatable\Translatable;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity
  9. */
  10. class TranslatableArticle implements Sluggable, Translatable
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @Gedmo\Translatable
  20. * @Gedmo\Sluggable
  21. * @ORM\Column(type="string", length=64)
  22. */
  23. private $title;
  24. /**
  25. * @Gedmo\Translatable
  26. * @Gedmo\Sluggable
  27. * @ORM\Column(type="string", length=16)
  28. */
  29. private $code;
  30. /**
  31. * @Gedmo\Translatable
  32. * @Gedmo\Slug
  33. * @ORM\Column(type="string", length=128)
  34. */
  35. private $slug;
  36. /**
  37. * @ORM\OneToMany(targetEntity="Comment", mappedBy="article")
  38. */
  39. private $comments;
  40. /**
  41. * @ORM\ManyToOne(targetEntity="Page", inversedBy="articles")
  42. */
  43. private $page;
  44. /**
  45. * @Gedmo\Locale
  46. * Used locale to override Translation listener`s locale
  47. */
  48. private $locale;
  49. public function addComment(Comment $comment)
  50. {
  51. $comment->setArticle($this);
  52. $this->comments[] = $comment;
  53. }
  54. public function getComments()
  55. {
  56. return $this->comments;
  57. }
  58. public function setPage($page)
  59. {
  60. $this->page = $page;
  61. }
  62. public function getId()
  63. {
  64. return $this->id;
  65. }
  66. public function setTitle($title)
  67. {
  68. $this->title = $title;
  69. }
  70. public function getTitle()
  71. {
  72. return $this->title;
  73. }
  74. public function setCode($code)
  75. {
  76. $this->code = $code;
  77. }
  78. public function getCode()
  79. {
  80. return $this->code;
  81. }
  82. public function getSlug()
  83. {
  84. return $this->slug;
  85. }
  86. public function setTranslatableLocale($locale)
  87. {
  88. $this->locale = $locale;
  89. }
  90. }