<?phpnamespace App\Entity;use App\Repository\ArmoireRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: ArmoireRepository::class)]class Armoire{//Déclarations des variables #[ORM\Id] #[ORM\Column(name: 'id_armoire',type: 'integer', nullable: false)] //Spécifie que la valeur générée est un ID auto-incrémenté #[ORM\GeneratedValue(strategy:'IDENTITY')] private ?int $id; #[ORM\Column(length: 255, nullable: false)] private ?string $nom = null; //Association #[ORM\OneToMany(mappedBy:'armoire', targetEntity: Classeur::class, orphanRemoval: true)] private ?Collection $classeurs; #[ORM\OneToMany(mappedBy:'armoire', targetEntity: Etagere::class, orphanRemoval: true)] private ?Collection $etageres; //Constructeur public function __construct() { $this->classeurs = new ArrayCollection(); $this->etageres = new ArrayCollection(); } //Getters et Setters /** * @return int|null */ public function getId(): ?int { return $this->id; } /** * @return string|null */ public function getNom(): ?string { return $this->nom; } /** * @param string|null $nom */ public function setNom(?string $nom): void { $this->nom = $nom; } //Fonctions des collections /** * @return Collection<int, Classeur> */ public function getClasseurs(): Collection { return $this->classeurs; } public function addClasseur(Classeur $classeur): self { if (!$this->classeurs->contains($classeur)) { $this->classeurs->add($classeur); $classeur->setArmoire($this); } return $this; } public function removeClasseur(Classeur $classeur): self { if ($this->classeurs->removeElement($classeur)) { // set the owning side to null (unless already changed) if ($classeur->getArmoire() === $this) { $classeur->setArmoire(null); } } return $this; } /** * @return Collection<int, Etagere> */ public function getEtageres(): Collection { return $this->etageres; } public function addEtagere(Etagere $etagere): self { if (!$this->etageres->contains($etagere)) { $this->etageres->add($etagere); $etagere->setArmoire($this); } return $this; } public function removeEtagere(Etagere $etagere): self { if ($this->etageres->removeElement($etagere)) { // set the owning side to null (unless already changed) if ($etagere->getArmoire() === $this) { $etagere->setArmoire(null); } } return $this; } public function __toString(): string { return $this->nom ?? ''; }}