src/Entity/IdeaBoxAnswer.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use JMS\Serializer\Annotation as Serializer;
  6. use JMS\Serializer\Annotation\Expose;
  7. use JMS\Serializer\Annotation\Groups;
  8. use App\Repository\IdeaBoxAnswerRepository;
  9. /**
  10. * @ORM\Entity(repositoryClass=IdeaBoxAnswerRepository::class)
  11. *
  12. * @Serializer\ExclusionPolicy("ALL")
  13. */
  14. class IdeaBoxAnswer
  15. {
  16. /**
  17. * @ORM\Id
  18. * @ORM\GeneratedValue
  19. * @ORM\Column(type="integer")
  20. *
  21. * @Expose
  22. * @Groups({
  23. * "idea_box_answer:id",
  24. * "idea_box_stats", "export_idea_box_datatable"
  25. * })
  26. */
  27. private $id;
  28. /**
  29. * @ORM\ManyToOne(targetEntity=IdeaBoxQuestion::class, inversedBy="answers")
  30. *
  31. * @Expose
  32. * @Groups({
  33. * "idea_box_answer:idea_box_question",
  34. * "export_idea_box_datatable"
  35. * })
  36. */
  37. private ?IdeaBoxQuestion $ideaBoxQuestion;
  38. /**
  39. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="ideaBoxAnswers")
  40. * @ORM\JoinColumn(nullable=false)
  41. *
  42. * @Expose
  43. * @Groups({
  44. * "idea_box_answer:user",
  45. * "export_idea_box_datatable"
  46. * })
  47. */
  48. private $user;
  49. /**
  50. * @ORM\Column(type="text", nullable=true)
  51. *
  52. * @Expose
  53. * @Groups({
  54. * "idea_box_answer:answer",
  55. * "idea_box_stats", "export_idea_box_datatable"
  56. * })
  57. */
  58. private ?string $answer;
  59. /**
  60. * @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="ideaBoxAnswer")
  61. *
  62. * @Expose
  63. * @Groups({
  64. * "idea_box_answer:idea_box_recipients",
  65. * "export_idea_box_datatable"
  66. * })
  67. */
  68. private $ideaBoxRecipients;
  69. public function __construct()
  70. {
  71. $this->user = new ArrayCollection();
  72. $this->ideaBoxRecipients = new ArrayCollection();
  73. }
  74. public function getId(): ?int
  75. {
  76. return $this->id;
  77. }
  78. public function getIdeaBoxQuestion(): ?IdeaBoxQuestion
  79. {
  80. return $this->ideaBoxQuestion;
  81. }
  82. public function setIdeaBoxQuestion( ?IdeaBoxQuestion $ideaBoxQuestion ): self
  83. {
  84. $this->ideaBoxQuestion = $ideaBoxQuestion;
  85. return $this;
  86. }
  87. public function getUser(): ArrayCollection
  88. {
  89. return $this->user;
  90. }
  91. public function setUser( ?User $user ): IdeaBoxAnswer
  92. {
  93. $this->user = $user;
  94. return $this;
  95. }
  96. public function getAnswer(): ?string
  97. {
  98. return $this->answer;
  99. }
  100. public function setAnswer( ?string $answer ): IdeaBoxAnswer
  101. {
  102. $this->answer = $answer;
  103. return $this;
  104. }
  105. public function getIdeaBoxRecipients()
  106. {
  107. return $this->ideaBoxRecipients;
  108. }
  109. public function addIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxAnswer
  110. {
  111. if ( !$this->ideaBoxRecipients->contains( $ideaBoxRecipient ) ) {
  112. $this->ideaBoxRecipients[] = $ideaBoxRecipient;
  113. $ideaBoxRecipient->setIdeaBoxAnswer( $this );
  114. }
  115. return $this;
  116. }
  117. public function removeIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxAnswer
  118. {
  119. if ( $this->ideaBoxRecipients->removeElement( $ideaBoxRecipient ) ) {
  120. // set the owning side to null (unless already changed)
  121. if ( $ideaBoxRecipient->getIdeaBoxAnswer() === $this ) {
  122. $ideaBoxRecipient->setIdeaBoxAnswer( NULL );
  123. }
  124. }
  125. return $this;
  126. }
  127. }