src/Entity/IdeaBoxQuestion.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\IdeaBoxQuestionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Expose;
  9. use JMS\Serializer\Annotation\Groups;
  10. /**
  11. * @ORM\Entity(repositoryClass=IdeaBoxQuestionRepository::class)
  12. *
  13. * @Serializer\ExclusionPolicy("ALL")
  14. */
  15. class IdeaBoxQuestion
  16. {
  17. /**
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. *
  22. * @Expose
  23. * @Groups({
  24. * "idea_box_question:id",
  25. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  26. * })
  27. */
  28. private $id;
  29. /**
  30. * @ORM\ManyToOne(targetEntity=IdeaBox::class, inversedBy="questions")
  31. *
  32. * @Expose
  33. * @Groups({
  34. * "idea_box_question:idea_box",
  35. * "export_idea_box_datatable"
  36. * })
  37. */
  38. private ?IdeaBox $ideaBox;
  39. /**
  40. * @ORM\OneToMany(targetEntity=IdeaBoxAnswer::class, mappedBy="ideaBoxQuestion", cascade={"remove"})
  41. *
  42. * @Expose
  43. * @Groups({
  44. * "idea_box_question:answers",
  45. * "export_idea_box_datatable"
  46. * })
  47. */
  48. private $answers;
  49. /**
  50. * @ORM\Column(type="boolean")
  51. */
  52. private $enabled;
  53. /**
  54. * @ORM\Column(type="text")
  55. *
  56. * @Expose
  57. * @Groups({
  58. * "idea_box_question:question",
  59. * "export_idea_box_datatable"
  60. * })
  61. */
  62. private ?string $question;
  63. /**
  64. * @ORM\Column(type="string", length=255, nullable=true)
  65. *
  66. * @Expose
  67. * @Groups({
  68. * "idea_box_question:type",
  69. * "idea_box_stats", "export_idea_box_datatable"
  70. * })
  71. */
  72. private ?string $type;
  73. /**
  74. * @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="ideaBoxQuestion")
  75. *
  76. * @Expose
  77. * @Groups({
  78. * "idea_box_question:idea_box_recipients",
  79. * "export_idea_box_datatable"
  80. * })
  81. */
  82. private $ideaBoxRecipients;
  83. public function __construct()
  84. {
  85. $this->answers = new ArrayCollection();
  86. $this->ideaBoxRecipients = new ArrayCollection();
  87. }
  88. public function getId(): ?int
  89. {
  90. return $this->id;
  91. }
  92. public function getIdeaBox(): ?IdeaBox
  93. {
  94. return $this->ideaBox;
  95. }
  96. public function setIdeaBox( ?IdeaBox $ideaBox ): IdeaBoxQuestion
  97. {
  98. $this->ideaBox = $ideaBox;
  99. return $this;
  100. }
  101. public function getAnswers(): Collection
  102. {
  103. return $this->answers;
  104. }
  105. public function addAnswer( IdeaBoxAnswer $answer ): IdeaBoxQuestion
  106. {
  107. if ( !$this->answers->contains( $answer ) ) {
  108. $this->answers[] = $answer;
  109. $answer->setIdeaBoxQuestion( $this );
  110. }
  111. return $this;
  112. }
  113. public function removeAnswer( IdeaBoxAnswer $answer ): IdeaBoxQuestion
  114. {
  115. if ( $this->answers->removeElement( $answer ) ) {
  116. // set the owning side to null (unless already changed)
  117. if ( $answer->getIdeaBoxQuestion() === $this ) {
  118. $answer->setIdeaBoxQuestion( NULL );
  119. }
  120. }
  121. return $this;
  122. }
  123. public function isEnabled(): ?bool
  124. {
  125. return $this->enabled;
  126. }
  127. public function setEnabled( bool $enabled ): IdeaBoxQuestion
  128. {
  129. $this->enabled = $enabled;
  130. return $this;
  131. }
  132. public function getQuestion(): ?string
  133. {
  134. return $this->question;
  135. }
  136. public function setQuestion( string $question ): IdeaBoxQuestion
  137. {
  138. $this->question = $question;
  139. return $this;
  140. }
  141. public function getType(): ?string
  142. {
  143. return $this->type;
  144. }
  145. public function setType( ?string $type ): IdeaBoxQuestion
  146. {
  147. $this->type = $type;
  148. return $this;
  149. }
  150. /**
  151. * @return Collection<int, IdeaBoxRecipient>
  152. */
  153. public function getIdeaBoxRecipients(): Collection
  154. {
  155. return $this->ideaBoxRecipients;
  156. }
  157. public function addIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxQuestion
  158. {
  159. if ( !$this->ideaBoxRecipients->contains( $ideaBoxRecipient ) ) {
  160. $this->ideaBoxRecipients[] = $ideaBoxRecipient;
  161. $ideaBoxRecipient->setIdeaBoxQuestion( $this );
  162. }
  163. return $this;
  164. }
  165. public function removeIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxQuestion
  166. {
  167. if ( $this->ideaBoxRecipients->removeElement( $ideaBoxRecipient ) ) {
  168. // set the owning side to null (unless already changed)
  169. if ( $ideaBoxRecipient->getIdeaBoxQuestion() === $this ) {
  170. $ideaBoxRecipient->setIdeaBoxQuestion( NULL );
  171. }
  172. }
  173. return $this;
  174. }
  175. }