<?phpnamespace App\Entity;use App\Repository\ClassOptionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: ClassOptionRepository::class)]class ClassOption{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $name = null; #[ORM\Column(length: 255, nullable: true)] private ?string $nameEn = null; #[ORM\ManyToOne(inversedBy: 'classOptions')] #[ORM\JoinColumn(nullable: false)] private ?ClassLevel $level = null; #[ORM\ManyToMany(targetEntity: TheClass::class, mappedBy: 'classOptions')] private Collection $theClasses; /** * Groupes de matières du programme national (équivalent national de SubjectGroup) * pour cette option de classe. */ #[ORM\OneToMany(mappedBy: 'classOption', targetEntity: SubjectGroupReference::class, orphanRemoval: true)] private Collection $subjectGroupReferences; /** * Référentiels de matières du programme national pour cette option de classe. */ #[ORM\OneToMany(mappedBy: 'classOption', targetEntity: SubjectReference::class, orphanRemoval: true)] private Collection $subjectReferences; public function __construct() { $this->theClasses = new ArrayCollection(); $this->subjectGroupReferences = new ArrayCollection(); $this->subjectReferences = new ArrayCollection(); } public function __toString(): string { return $this->name . ' - ' . $this->nameEn; } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getNameEn(): ?string { return $this->nameEn; } public function setNameEn(?string $nameEn): static { $this->nameEn = $nameEn; return $this; } public function getLevel(): ?ClassLevel { return $this->level; } public function setLevel(?ClassLevel $level): static { $this->level = $level; return $this; } /** * @return Collection<int, TheClass> */ public function getTheClasses(): Collection { return $this->theClasses; } public function addTheClass(TheClass $theClass): static { if (!$this->theClasses->contains($theClass)) { $this->theClasses->add($theClass); $theClass->addClassOption($this); } return $this; } public function removeTheClass(TheClass $theClass): static { if ($this->theClasses->removeElement($theClass)) { $theClass->removeClassOption($this); } return $this; } /** * @return Collection<int, SubjectGroupReference> */ public function getSubjectGroupReferences(): Collection { return $this->subjectGroupReferences; } public function addSubjectGroupReference(SubjectGroupReference $subjectGroupReference): static { if (!$this->subjectGroupReferences->contains($subjectGroupReference)) { $this->subjectGroupReferences->add($subjectGroupReference); $subjectGroupReference->setClassOption($this); } return $this; } public function removeSubjectGroupReference(SubjectGroupReference $subjectGroupReference): static { if ($this->subjectGroupReferences->removeElement($subjectGroupReference)) { if ($subjectGroupReference->getClassOption() === $this) { $subjectGroupReference->setClassOption(null); } } return $this; } /** * @return Collection<int, SubjectReference> */ public function getSubjectReferences(): Collection { return $this->subjectReferences; } public function addSubjectReference(SubjectReference $subjectReference): static { if (!$this->subjectReferences->contains($subjectReference)) { $this->subjectReferences->add($subjectReference); $subjectReference->setClassOption($this); } return $this; } public function removeSubjectReference(SubjectReference $subjectReference): static { if ($this->subjectReferences->removeElement($subjectReference)) { if ($subjectReference->getClassOption() === $this) { $subjectReference->setClassOption(null); } } return $this; }}