src/Entity/Forme.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FormeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use phpDocumentor\Reflection\Types\Integer;
  8. #[ORM\Entity(repositoryClassFormeRepository::class)]
  9. class Forme
  10. {
  11.     //Déclarations des variables
  12.     #[ORM\Id]
  13.     #[ORM\Column(name'id_forme',type'integer'nullablefalse)]
  14.     //Spécifie que la valeur générée est un ID auto-incrémenté
  15.     #[ORM\GeneratedValue(strategy:'IDENTITY')]
  16.     private ?int $id;
  17.     #[ORM\Column(length255nullablefalse)]
  18.     private ?string $nom null;
  19.     //Association
  20.     #[ORM\OneToMany(mappedBy:'forme'targetEntityModel::class, orphanRemovaltrue)]
  21.     private Collection $models;
  22.     #[ORM\ManyToOne(targetEntityTypeCollection::class, inversedBy'formes')]
  23.     #[ORM\JoinColumn(referencedColumnName'id_type_collection'nullablefalse)]
  24.     private ?TypeCollection $typeCollection null;
  25.     //Constructeur
  26.     public function __construct()
  27.     {
  28.         $this->models = new ArrayCollection();
  29.     }
  30.     //Getters et Setters
  31.     /**
  32.      * @return int|null
  33.      */
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     /**
  39.      * @return string|null
  40.      */
  41.     public function getNom(): ?string
  42.     {
  43.         return $this->nom;
  44.     }
  45.     /**
  46.      * @param string|null $nom
  47.      */
  48.     public function setNom(?string $nom): void
  49.     {
  50.         $this->nom $nom;
  51.     }
  52.     //Fonctions collections
  53.     /**
  54.      * @return Collection<int, Model>
  55.      */
  56.     public function getModels(): Collection
  57.     {
  58.         return $this->models;
  59.     }
  60.     public function addModel(Model $model): self
  61.     {
  62.         if (!$this->models->contains($model)) {
  63.             $this->models->add($model);
  64.             $model->addForme($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeModel(Model $model): self
  69.     {
  70.         if ($this->models->removeElement($model)) {
  71.             // set the owning side to null (unless already changed)
  72.             if ($model->getForme() === $this) {
  73.                 $model->addForme(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78.     public function getTypeCollection(): ?TypeCollection
  79.     {
  80.         return $this->typeCollection;
  81.     }
  82.     public function setTypeCollection(?TypeCollection $typeCollection): self
  83.     {
  84.         $this->typeCollection $typeCollection;
  85.         return $this;
  86.     }
  87.     public function __toString(): string
  88.     {
  89.         return $this->nom;
  90.     }
  91. }