src/Entity/Classeur.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClasseurRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use phpDocumentor\Reflection\Types\Integer;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass:ClasseurRepository ::class)]
  9. class Classeur
  10. {
  11.     //Déclarations des variables
  12.     #[ORM\Id]
  13.     #[ORM\Column(name'id_classeur',type'integer'nullablefalse)]
  14.     #[ORM\GeneratedValue(strategy:'IDENTITY')]
  15.     private ?int $id;
  16.     #[ORM\Column(length255nullablefalse)]
  17.     private ?string $nom null;
  18.     #[ORM\Column(length255nullablefalse)]
  19.     private ?string $couleur null;
  20.     //Associations
  21.     #[ORM\OneToMany(mappedBy:'classeur'targetEntityPage::class, orphanRemovaltrue)]
  22.     private ?Collection $pages;
  23.     #[ORM\ManyToOne(targetEntityArmoire::class, cascade: ['persist'], fetch"EAGER"inversedBy'classeurs')]
  24.     #[ORM\JoinColumn(referencedColumnName'id_armoire'nullablefalse)]
  25.     private ?Armoire $armoire null;
  26.     #[ORM\ManyToOne(targetEntityEtagere::class, cascade: ['persist'], fetch"EAGER"inversedBy'classeurs')]
  27.     #[ORM\JoinColumn(referencedColumnName'id_etagere'nullablefalse)]
  28.     private ?Etagere $etagere null;
  29.     //Constructeur
  30.     public function __construct()
  31.     {
  32.         $this->pages = new ArrayCollection();
  33.     }
  34.     //Getters et Setters
  35.     //Fonction des collections
  36.     /**
  37.      * @return Collection<int, Page>
  38.      */
  39.     public function getPages(): Collection
  40.     {
  41.         return $this->pages;
  42.     }
  43.     public function addPage(Page $page): self
  44.     {
  45.         if (!$this->pages->contains($page)) {
  46.             $this->pages->add($page);
  47.             $page->setClasseur($this);
  48.         }
  49.         return $this;
  50.     }
  51.     public function removePage(page $page): self
  52.     {
  53.         if ($this->pages->removeElement($page)) {
  54.             // set the owning side to null (unless already changed)
  55.             if ($page->getClasseur() === $this) {
  56.                 $page->setClasseur(null);
  57.             }
  58.         }
  59.         return $this;
  60.     }
  61.     //Fonctions des variables
  62.     /**
  63.      * @return int|null
  64.      */
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     /**
  70.      * @return string|null
  71.      */
  72.     public function getNom(): ?string
  73.     {
  74.         return $this->nom;
  75.     }
  76.     /**
  77.      * @param string|null $nom
  78.      */
  79.     public function setNom(?string $nom): void
  80.     {
  81.         $this->nom $nom;
  82.     }
  83.     /**
  84.      * @return string|null
  85.      */
  86.     public function getCouleur(): ?string
  87.     {
  88.         return $this->couleur;
  89.     }
  90.     /**
  91.      * @param string|null $couleur
  92.      */
  93.     public function setCouleur(?string $couleur): void
  94.     {
  95.         $this->couleur $couleur;
  96.     }
  97.     /**
  98.      * @return Armoire|null
  99.      */
  100.     public function getArmoire(): ?Armoire
  101.     {
  102.         return $this->armoire;
  103.     }
  104.     /**
  105.      * @param Armoire|null $armoire
  106.      */
  107.     public function setArmoire(?Armoire $armoire): void
  108.     {
  109.         $this->armoire $armoire;
  110.     }
  111.     /**
  112.      * @return Etagere|null
  113.      */
  114.     public function getEtagere(): ?Etagere
  115.     {
  116.         return $this->etagere;
  117.     }
  118.     /**
  119.      * @param Etagere|null $etagere
  120.      */
  121.     public function setEtagere(?Etagere $etagere): void
  122.     {
  123.         $this->etagere $etagere;
  124.     }
  125.     /**
  126.      * @return string|null
  127.      */
  128.     public function getEtagereNom(): ?string
  129.     {
  130.         $etagere $this->etagere;
  131.         if ($etagere){
  132.             return $etagere->getNom();
  133.         }
  134.         return null;
  135.     }
  136.     /**
  137.      * @return string|null
  138.      */
  139.     public function getArmoireNom(): ?string
  140.     {
  141.         $armoire $this->armoire;
  142.         if ($armoire){
  143.             return $armoire->getNom();
  144.         }
  145.         return null;
  146.     }
  147.     public function __toString(): string
  148.     {
  149.         return $this->nom ?? '';
  150.     }
  151. }