src/Entity/ClassOption.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClassOptionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassClassOptionRepository::class)]
  8. class ClassOption
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $name null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $nameEn null;
  18.     #[ORM\ManyToOne(inversedBy'classOptions')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?ClassLevel $level null;
  21.     #[ORM\ManyToMany(targetEntityTheClass::class, mappedBy'classOptions')]
  22.     private Collection $theClasses;
  23.     /**
  24.      * Groupes de matières du programme national (équivalent national de SubjectGroup)
  25.      * pour cette option de classe.
  26.      */
  27.     #[ORM\OneToMany(mappedBy'classOption'targetEntitySubjectGroupReference::class, orphanRemovaltrue)]
  28.     private Collection $subjectGroupReferences;
  29.     /**
  30.      * Référentiels de matières du programme national pour cette option de classe.
  31.      */
  32.     #[ORM\OneToMany(mappedBy'classOption'targetEntitySubjectReference::class, orphanRemovaltrue)]
  33.     private Collection $subjectReferences;
  34.     public function __construct()
  35.     {
  36.         $this->theClasses = new ArrayCollection();
  37.         $this->subjectGroupReferences = new ArrayCollection();
  38.         $this->subjectReferences = new ArrayCollection();
  39.     }
  40.     
  41.     public function __toString(): string
  42.     {
  43.         return $this->name ' - ' $this->nameEn;
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): static
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     public function getNameEn(): ?string
  59.     {
  60.         return $this->nameEn;
  61.     }
  62.     public function setNameEn(?string $nameEn): static
  63.     {
  64.         $this->nameEn $nameEn;
  65.         return $this;
  66.     }
  67.     public function getLevel(): ?ClassLevel
  68.     {
  69.         return $this->level;
  70.     }
  71.     public function setLevel(?ClassLevel $level): static
  72.     {
  73.         $this->level $level;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return Collection<int, TheClass>
  78.      */
  79.     public function getTheClasses(): Collection
  80.     {
  81.         return $this->theClasses;
  82.     }
  83.     public function addTheClass(TheClass $theClass): static
  84.     {
  85.         if (!$this->theClasses->contains($theClass)) {
  86.             $this->theClasses->add($theClass);
  87.             $theClass->addClassOption($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeTheClass(TheClass $theClass): static
  92.     {
  93.         if ($this->theClasses->removeElement($theClass)) {
  94.             $theClass->removeClassOption($this);
  95.         }
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, SubjectGroupReference>
  100.      */
  101.     public function getSubjectGroupReferences(): Collection
  102.     {
  103.         return $this->subjectGroupReferences;
  104.     }
  105.     public function addSubjectGroupReference(SubjectGroupReference $subjectGroupReference): static
  106.     {
  107.         if (!$this->subjectGroupReferences->contains($subjectGroupReference)) {
  108.             $this->subjectGroupReferences->add($subjectGroupReference);
  109.             $subjectGroupReference->setClassOption($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeSubjectGroupReference(SubjectGroupReference $subjectGroupReference): static
  114.     {
  115.         if ($this->subjectGroupReferences->removeElement($subjectGroupReference)) {
  116.             if ($subjectGroupReference->getClassOption() === $this) {
  117.                 $subjectGroupReference->setClassOption(null);
  118.             }
  119.         }
  120.         return $this;
  121.     }
  122.     /**
  123.      * @return Collection<int, SubjectReference>
  124.      */
  125.     public function getSubjectReferences(): Collection
  126.     {
  127.         return $this->subjectReferences;
  128.     }
  129.     public function addSubjectReference(SubjectReference $subjectReference): static
  130.     {
  131.         if (!$this->subjectReferences->contains($subjectReference)) {
  132.             $this->subjectReferences->add($subjectReference);
  133.             $subjectReference->setClassOption($this);
  134.         }
  135.         return $this;
  136.     }
  137.     public function removeSubjectReference(SubjectReference $subjectReference): static
  138.     {
  139.         if ($this->subjectReferences->removeElement($subjectReference)) {
  140.             if ($subjectReference->getClassOption() === $this) {
  141.                 $subjectReference->setClassOption(null);
  142.             }
  143.         }
  144.         return $this;
  145.     }
  146. }