<?phpnamespace App\Entity;use App\Repository\EtagereRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use phpDocumentor\Reflection\Types\Integer;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: EtagereRepository::class)]class Etagere{//Déclarations des variables #[ORM\Id] #[ORM\Column(name: 'id_etagere',type: 'integer', nullable: false)] #[ORM\GeneratedValue(strategy: 'IDENTITY')] private ?int $id; #[ORM\Column(length: 255, nullable: false)] private ?string $nom = null; //Associations //On ajoute la relation ManyToOne où Photo est le propriétaire (=Many), (=inversedBy) #[ORM\ManyToOne(targetEntity: Armoire::class, inversedBy: 'etageres')] #[ORM\JoinColumn(referencedColumnName: 'id_armoire', nullable: false)] private ?Armoire $armoire = null; #[ORM\OneToMany(mappedBy:'etagere', targetEntity: Classeur::class, orphanRemoval: true)] private ?Collection $classeurs; //Constructeur public function __construct() { $this->classeurs = 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; } /** * @return Armoire|null */ public function getArmoire(): ?Armoire { return $this->armoire; } /** * @param Armoire|null $armoire */ public function setArmoire(?Armoire $armoire): void { $this->armoire = $armoire; } //Fonctions des collections /** * @return Collection<int, Classeur> */ public function getClasseur(): Collection { return $this->classeurs; } public function addClasseur(Classeur $classeur): self { if (!$this->classeurs->contains($classeur)) { $this->classeurs->add($classeur); $classeur->setEtagere($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->getEtagere() === $this) { $classeur->setEtagere(null); } } return $this; } public function __toString(): string { return $this->nom ?? ''; }}