TranslatableArticle.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. * @ORM\Column(type="string", length=64)
  21. */
  22. private $title;
  23. /**
  24. * @Gedmo\Translatable
  25. * @ORM\Column(type="string", length=16)
  26. */
  27. private $code;
  28. /**
  29. * @Gedmo\Translatable
  30. * @Gedmo\Slug(fields={"title", "code"})
  31. * @ORM\Column(type="string", length=128)
  32. */
  33. private $slug;
  34. /**
  35. * @ORM\OneToMany(targetEntity="Comment", mappedBy="article")
  36. */
  37. private $comments;
  38. /**
  39. * @ORM\ManyToOne(targetEntity="Page", inversedBy="articles")
  40. */
  41. private $page;
  42. /**
  43. * @Gedmo\Locale
  44. * Used locale to override Translation listener`s locale
  45. */
  46. private $locale;
  47. public function addComment(Comment $comment)
  48. {
  49. $comment->setArticle($this);
  50. $this->comments[] = $comment;
  51. }
  52. public function getComments()
  53. {
  54. return $this->comments;
  55. }
  56. public function setPage($page)
  57. {
  58. $this->page = $page;
  59. }
  60. public function getId()
  61. {
  62. return $this->id;
  63. }
  64. public function setTitle($title)
  65. {
  66. $this->title = $title;
  67. }
  68. public function getTitle()
  69. {
  70. return $this->title;
  71. }
  72. public function setCode($code)
  73. {
  74. $this->code = $code;
  75. }
  76. public function getCode()
  77. {
  78. return $this->code;
  79. }
  80. public function getSlug()
  81. {
  82. return $this->slug;
  83. }
  84. public function setTranslatableLocale($locale)
  85. {
  86. $this->locale = $locale;
  87. }
  88. }