src/Entity/Survey/Answer.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Survey;
  3. use App\Entity\PrimaryIdTrait;
  4. use App\Repository\Survey\AnswerRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Symfony\Component\Cache\Adapter\FilesystemAdapter;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. #[ORM\Entity(repositoryClassAnswerRepository::class)]
  12. class Answer
  13. {
  14.     use PrimaryIdTrait;
  15.     use TimestampableEntity;
  16.     #[ORM\Column(type'string')]
  17.     #[Groups(['survey''childrenQuestions'])]
  18.     private string $wording;
  19.     #[ORM\OneToMany(targetEntity'App\Entity\Survey\QuestionAnswer'mappedBy'answer'cascade: ['remove'])]
  20.     public $questionAnswer;
  21.     #[ORM\OneToMany(targetEntity'App\Entity\Survey\AnswerQuestion'mappedBy'answer'cascade: ['persist''remove'], orphanRemovaltrue)]
  22.     #[ORM\OrderBy(['sort' => 'ASC'])]
  23.     public $answerQuestion;
  24.     public function __construct()
  25.     {
  26.         $this->questionAnswer = new ArrayCollection();
  27.         $this->answerQuestion = new ArrayCollection();
  28.     }
  29.     public function getWording(): string
  30.     {
  31.         return $this->wording;
  32.     }
  33.     public function setWording(string $wording): void
  34.     {
  35.         $this->wording $wording;
  36.     }
  37.     /**
  38.      * @return Collection|QuestionAnswer[]
  39.      */
  40.     public function getQuestionAnswer(): Collection
  41.     {
  42.         return $this->questionAnswer;
  43.     }
  44.     /**
  45.      * @return Collection|AnswerQuestion[]
  46.      */
  47.     public function getAnswerQuestion(): Collection
  48.     {
  49.         return $this->answerQuestion;
  50.     }
  51.     public function addAnswerQuestion(AnswerQuestion $answerQuestion): void
  52.     {
  53.         $answerQuestion->setAnswer($this);
  54.         $this->answerQuestion->add($answerQuestion);
  55.     }
  56.     public function removeAnswerQuestion(AnswerQuestion $answerQuestion): void
  57.     {
  58.         if ($this->answerQuestion->contains($answerQuestion)) {
  59.             $this->answerQuestion->removeElement($answerQuestion);
  60.         }
  61.     }
  62. }