src/Entity/SubThematic.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubThematicRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSubThematicRepository::class)]
  9. class SubThematic
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $name null;
  17.     #[ORM\OneToMany(mappedBy'subThematic'targetEntityQuestion::class, fetch"EAGER")]
  18.     private Collection $questions;
  19.     #[ORM\ManyToOne(inversedBy'subThematics')]
  20.     #[ORM\JoinColumn(nullablefalse)]
  21.     private ?Questionnaire $questionnaire null;
  22.     public function __construct()
  23.     {
  24.         $this->questions = new ArrayCollection();
  25.     }
  26.     public function __toString()
  27.     {
  28.         return $this->name;
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getName(): ?string
  35.     {
  36.         return $this->name;
  37.     }
  38.     public function setName(string $name): self
  39.     {
  40.         $this->name $name;
  41.         return $this;
  42.     }
  43.     /**
  44.      * @return Collection<int, Question>
  45.      */
  46.     public function getQuestions(): Collection
  47.     {
  48.         return $this->questions;
  49.     }
  50.     public function addQuestion(Question $question): self
  51.     {
  52.         if (!$this->questions->contains($question)) {
  53.             $this->questions->add($question);
  54.             $question->setSubThematic($this);
  55.         }
  56.         return $this;
  57.     }
  58.     public function removeQuestion(Question $question): self
  59.     {
  60.         if ($this->questions->removeElement($question)) {
  61.             // set the owning side to null (unless already changed)
  62.             if ($question->getSubThematic() === $this) {
  63.                 $question->setSubThematic(null);
  64.             }
  65.         }
  66.         return $this;
  67.     }
  68.     public function getQuestionnaire(): ?Questionnaire
  69.     {
  70.         return $this->questionnaire;
  71.     }
  72.     public function setQuestionnaire(?Questionnaire $questionnaire): self
  73.     {
  74.         $this->questionnaire $questionnaire;
  75.         return $this;
  76.     }
  77. }