src/Entity/Proposition.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PropositionRepository;
  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. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassPropositionRepository::class)]
  10. class Proposition
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\ManyToOne(inversedBy'propositions')]
  17.     #[ORM\JoinColumn(nullablefalse)]
  18.     private ?Quiz $quiz null;
  19.     #[ORM\Column(typeTypes::TEXT)]
  20.     #[Assert\NotBlank(message"Ne peut ĂȘtre vide !")]
  21.     #[Assert\NotNull(message"Ne peut ĂȘtre nul !")]
  22.     private ?string $content null;
  23.     #[ORM\Column]
  24.     private ?bool $isTrue null;
  25.     #[ORM\OneToMany(mappedBy'proposition'targetEntityReponse::class, orphanRemovaltrue)]
  26.     private Collection $reponses;
  27.     public function __construct()
  28.     {
  29.         $this->reponses = new ArrayCollection();
  30.         $this->isTrue false;
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getQuiz(): ?Quiz
  37.     {
  38.         return $this->quiz;
  39.     }
  40.     public function setQuiz(?Quiz $quiz): self
  41.     {
  42.         $this->quiz $quiz;
  43.         return $this;
  44.     }
  45.     public function getContent(): ?string
  46.     {
  47.         return $this->content;
  48.     }
  49.     public function setContent(string $content): self
  50.     {
  51.         $this->content $content;
  52.         return $this;
  53.     }
  54.     public function isIsTrue(): ?bool
  55.     {
  56.         return $this->isTrue;
  57.     }
  58.     public function setIsTrue(bool $isTrue): self
  59.     {
  60.         $this->isTrue $isTrue;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, Reponse>
  65.      */
  66.     public function getReponses(): Collection
  67.     {
  68.         return $this->reponses;
  69.     }
  70.     public function addReponse(Reponse $reponse): self
  71.     {
  72.         if (!$this->reponses->contains($reponse)) {
  73.             $this->reponses->add($reponse);
  74.             $reponse->setProposition($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeReponse(Reponse $reponse): self
  79.     {
  80.         if ($this->reponses->removeElement($reponse)) {
  81.             // set the owning side to null (unless already changed)
  82.             if ($reponse->getProposition() === $this) {
  83.                 $reponse->setProposition(null);
  84.             }
  85.         }
  86.         return $this;
  87.     }
  88. }