<?phpnamespace App\Entity;use App\Repository\SubjectGroupReferenceRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use App\Entity\Traits\Timestampable;/** * Groupe de matières national (équivalent national de SubjectGroup). * * Exemple : "Matières Littéraires", "Matières Scientifiques", "Matières * Complémentaires" pour la ClassOption "3ème". * * Créé par le superadmin. Chaque SubjectReference s'y rattache, ce qui * permet de reproduire la même organisation par groupe que dans les * bulletins (cf. SubjectGroup), mais au niveau du programme national. */#[ORM\HasLifecycleCallbacks]#[ORM\Entity(repositoryClass: SubjectGroupReferenceRepository::class)]class SubjectGroupReference{ use Timestampable; #[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: 'subjectGroupReferences')] #[ORM\JoinColumn(nullable: false)] private ?ClassOption $classOption = null; #[ORM\OneToMany(mappedBy: 'subjectGroupReference', targetEntity: SubjectReference::class)] private Collection $subjectReferences; #[ORM\ManyToOne] private ?User $author = null; #[ORM\OneToMany(mappedBy: 'reference', targetEntity: SubjectGroup::class)] private Collection $subjectGroups; public function __construct() { $this->subjectReferences = new ArrayCollection(); $this->subjectGroups = new ArrayCollection(); } public function __toString(): string { return $this->name . ' (' . ($this->classOption?->getName() ?? '') . ')'; } 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 getClassOption(): ?ClassOption { return $this->classOption; } public function setClassOption(?ClassOption $classOption): static { $this->classOption = $classOption; 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->setSubjectGroupReference($this); } return $this; } public function removeSubjectReference(SubjectReference $subjectReference): static { if ($this->subjectReferences->removeElement($subjectReference)) { if ($subjectReference->getSubjectGroupReference() === $this) { $subjectReference->setSubjectGroupReference(null); } } return $this; } public function getAuthor(): ?User { return $this->author; } public function setAuthor(?User $author): static { $this->author = $author; return $this; } /** * @return Collection<int, SubjectGroup> */ public function getSubjectGroups(): Collection { return $this->subjectGroups; } public function addSubjectGroup(SubjectGroup $subjectGroup): static { if (!$this->subjectGroups->contains($subjectGroup)) { $this->subjectGroups->add($subjectGroup); $subjectGroup->setReference($this); } return $this; } public function removeSubjectGroup(SubjectGroup $subjectGroup): static { if ($this->subjectGroups->removeElement($subjectGroup)) { // set the owning side to null (unless already changed) if ($subjectGroup->getReference() === $this) { $subjectGroup->setReference(null); } } return $this; }}