<?php
namespace App\Entity\Survey;
use App\Entity\PrimaryIdTrait;
use App\Repository\Survey\AnswerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: AnswerRepository::class)]
class Answer
{
use PrimaryIdTrait;
use TimestampableEntity;
#[ORM\Column(type: 'string')]
#[Groups(['survey', 'childrenQuestions'])]
private string $wording;
#[ORM\OneToMany(targetEntity: 'App\Entity\Survey\QuestionAnswer', mappedBy: 'answer', cascade: ['remove'])]
public $questionAnswer;
#[ORM\OneToMany(targetEntity: 'App\Entity\Survey\AnswerQuestion', mappedBy: 'answer', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OrderBy(['sort' => 'ASC'])]
public $answerQuestion;
public function __construct()
{
$this->questionAnswer = new ArrayCollection();
$this->answerQuestion = new ArrayCollection();
}
public function getWording(): string
{
return $this->wording;
}
public function setWording(string $wording): void
{
$this->wording = $wording;
}
/**
* @return Collection|QuestionAnswer[]
*/
public function getQuestionAnswer(): Collection
{
return $this->questionAnswer;
}
/**
* @return Collection|AnswerQuestion[]
*/
public function getAnswerQuestion(): Collection
{
return $this->answerQuestion;
}
public function addAnswerQuestion(AnswerQuestion $answerQuestion): void
{
$answerQuestion->setAnswer($this);
$this->answerQuestion->add($answerQuestion);
}
public function removeAnswerQuestion(AnswerQuestion $answerQuestion): void
{
if ($this->answerQuestion->contains($answerQuestion)) {
$this->answerQuestion->removeElement($answerQuestion);
}
}
}