File: /var/www/dvpis2026/dvpis.kaunokolegija.lt/src/Entity/Poll/AnswerField.php
<?php
namespace App\Entity\Poll;
use App\Entity\Ktv;
use App\Entity\Meov;
use App\Entity\Tmmv;
use App\Repository\Poll\AnswerFieldRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
#[ORM\Table(name: 'poll_answer_field')]
#[ORM\Entity(repositoryClass: AnswerFieldRepository::class)]
class AnswerField
{
#[ORM\Column]
#[ORM\Id]
#[ORM\GeneratedValue]
private ?int $id = null;
/**
* @var string
*/
#[ORM\Column(name: 'name', type: 'string', length: 255)]
private $name;
/**
* @var string
*/
#[ORM\Column(name: 'name_en', type: 'string', length: 255)]
private $nameEn;
/**
* @var string
*/
#[ORM\Column(name: 'type', type: 'string', length: 255)]
private $type;
#[ORM\JoinColumn(name: 'poll_id', referencedColumnName: 'id', nullable: false)]
#[ORM\ManyToOne(targetEntity: Poll::class, inversedBy: 'answerFields')]
private ?Poll $poll;
#[ORM\OneToMany(mappedBy: 'answerField', targetEntity: Answer::class)]
private Collection $answers;
#[ORM\OneToMany(mappedBy: 'answerField', targetEntity: AnswerFieldChoise::class)]
private Collection $answerFieldChoises;
#[ORM\OneToMany(mappedBy: 'answerField', targetEntity: Tmmv::class)]
private Collection $tmmvs;
#[ORM\OneToMany(mappedBy: 'answerField', targetEntity: Meov::class)]
private Collection $meovs;
#[ORM\OneToMany(mappedBy: 'answerField', targetEntity: Ktv::class)]
private Collection $ktvs;
public function __construct()
{
$this->answers = new ArrayCollection();
$this->answerFieldChoises = new ArrayCollection();
$this->tmmvs = new ArrayCollection();
$this->meovs = new ArrayCollection();
$this->ktvs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setType(string $type): static
{
$this->type = $type;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function getPoll(): ?Poll
{
return $this->poll;
}
public function setPoll(?Poll $poll): static
{
$this->poll = $poll;
return $this;
}
public function __toString()
{
return $this->name . ' (' . $this->poll . ')';
}
/**
* @return Collection<int, Answer>
*/
public function getAnswers(): Collection
{
return $this->answers;
}
public function setAnswers($answers)
{
$this->answers = $answers;
return $this;
}
/**
* @return Collection<int, AnswerFieldChoise>
*/
public function getAnswerFieldChoises(): Collection
{
return $this->answerFieldChoises;
}
public function setAnswerFieldChoises($answerFieldChoises)
{
$this->answerFieldChoises = $answerFieldChoises;
return $this;
}
/**
* @return Collection<int, Tmmv>
*/
public function getTmmvs(): Collection
{
return $this->tmmvs;
}
public function setTmmvs($tmmvs)
{
$this->tmmvs = $tmmvs;
return $this;
}
/**
* @return Collection<int, Meov>
*/
public function getMeovs(): Collection
{
return $this->meovs;
}
public function setMeovs($meovs)
{
$this->meovs = $meovs;
return $this;
}
/**
* @return Collection<int, Ktv>
*/
public function getKtvs(): Collection
{
return $this->ktvs;
}
public function setKtvs($ktvs)
{
$this->ktvs = $ktvs;
return $this;
}
public function getNameEn(): ?string
{
return $this->nameEn;
}
public function setNameEn(string $nameEn): static
{
$this->nameEn = $nameEn;
return $this;
}
public function addAnswer(Answer $answer): static
{
if (!$this->answers->contains($answer)) {
$this->answers->add($answer);
$answer->setAnswerField($this);
}
return $this;
}
public function removeAnswer(Answer $answer): static
{
if ($this->answers->removeElement($answer)) {
// set the owning side to null (unless already changed)
if ($answer->getAnswerField() === $this) {
$answer->setAnswerField(null);
}
}
return $this;
}
public function addAnswerFieldChoise(AnswerFieldChoise $answerFieldChoise): static
{
if (!$this->answerFieldChoises->contains($answerFieldChoise)) {
$this->answerFieldChoises->add($answerFieldChoise);
$answerFieldChoise->setAnswerField($this);
}
return $this;
}
public function removeAnswerFieldChoise(AnswerFieldChoise $answerFieldChoise): static
{
if ($this->answerFieldChoises->removeElement($answerFieldChoise)) {
// set the owning side to null (unless already changed)
if ($answerFieldChoise->getAnswerField() === $this) {
$answerFieldChoise->setAnswerField(null);
}
}
return $this;
}
public function addTmmv(Tmmv $tmmv): static
{
if (!$this->tmmvs->contains($tmmv)) {
$this->tmmvs->add($tmmv);
$tmmv->setAnswerField($this);
}
return $this;
}
public function removeTmmv(Tmmv $tmmv): static
{
if ($this->tmmvs->removeElement($tmmv)) {
// set the owning side to null (unless already changed)
if ($tmmv->getAnswerField() === $this) {
$tmmv->setAnswerField(null);
}
}
return $this;
}
public function addMeov(Meov $meov): static
{
if (!$this->meovs->contains($meov)) {
$this->meovs->add($meov);
$meov->setAnswerField($this);
}
return $this;
}
public function removeMeov(Meov $meov): static
{
if ($this->meovs->removeElement($meov)) {
// set the owning side to null (unless already changed)
if ($meov->getAnswerField() === $this) {
$meov->setAnswerField(null);
}
}
return $this;
}
public function addKtv(Ktv $ktv): static
{
if (!$this->ktvs->contains($ktv)) {
$this->ktvs->add($ktv);
$ktv->setAnswerField($this);
}
return $this;
}
public function removeKtv(Ktv $ktv): static
{
if ($this->ktvs->removeElement($ktv)) {
// set the owning side to null (unless already changed)
if ($ktv->getAnswerField() === $this) {
$ktv->setAnswerField(null);
}
}
return $this;
}
}