src/CMSBundle/Entity/Faq.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\CMSBundle\Entity;
  3. use App\CMSBundle\Entity\Translation\FaqTranslation;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use PN\LocaleBundle\Model\LocaleTrait;
  8. use PN\LocaleBundle\Model\Translatable;
  9. use PN\ServiceBundle\Interfaces\DateTimeInterface;
  10. use PN\ServiceBundle\Model\DateTimeTrait;
  11. /**
  12. * Faq
  13. *
  14. * @ORM\HasLifecycleCallbacks
  15. * @ORM\Table(name="faq")
  16. * @ORM\Entity(repositoryClass="App\CMSBundle\Repository\FaqRepository")
  17. */
  18. class Faq implements DateTimeInterface, Translatable
  19. {
  20. use DateTimeTrait,
  21. LocaleTrait;
  22. /**
  23. * @ORM\Column(name="id", type="integer")
  24. * @ORM\Id
  25. * @ORM\GeneratedValue(strategy="AUTO")
  26. */
  27. private ?int $id = null;
  28. /**
  29. * @ORM\Column(name="question", type="text")
  30. */
  31. private ?string $question = null;
  32. /**
  33. * @ORM\Column(name="answer", type="text")
  34. */
  35. private ?string $answer = null;
  36. /**
  37. * @ORM\Column(name="publish", type="boolean")
  38. */
  39. private bool $publish = true;
  40. /**
  41. * @ORM\OneToMany(targetEntity="App\CMSBundle\Entity\Translation\FaqTranslation", mappedBy="translatable", cascade={"ALL"}, orphanRemoval=true)
  42. */
  43. private Collection $translations;
  44. public function __construct()
  45. {
  46. $this->translations = new ArrayCollection();
  47. }
  48. public function getId(): ?int
  49. {
  50. return $this->id;
  51. }
  52. public function getQuestion(): ?string
  53. {
  54. return $this->question;
  55. }
  56. public function setQuestion(string $question): static
  57. {
  58. $this->question = $question;
  59. return $this;
  60. }
  61. public function getAnswer(): ?string
  62. {
  63. return $this->answer;
  64. }
  65. public function setAnswer(string $answer): static
  66. {
  67. $this->answer = $answer;
  68. return $this;
  69. }
  70. public function isPublish(): ?bool
  71. {
  72. return $this->publish;
  73. }
  74. public function setPublish(bool $publish): static
  75. {
  76. $this->publish = $publish;
  77. return $this;
  78. }
  79. /**
  80. * @return Collection<int, FaqTranslation>
  81. */
  82. public function getTranslations(): Collection
  83. {
  84. return $this->translations;
  85. }
  86. public function addTranslation(FaqTranslation $translation): static
  87. {
  88. if (!$this->translations->contains($translation)) {
  89. $this->translations->add($translation);
  90. $translation->setTranslatable($this);
  91. }
  92. return $this;
  93. }
  94. public function removeTranslation(FaqTranslation $translation): static
  95. {
  96. if ($this->translations->removeElement($translation)) {
  97. // set the owning side to null (unless already changed)
  98. if ($translation->getTranslatable() === $this) {
  99. $translation->setTranslatable(null);
  100. }
  101. }
  102. return $this;
  103. }
  104. }