src/Entity/Declination.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DeclinationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=DeclinationRepository::class)
  9.  */
  10. class Declination
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\ManyToMany(targetEntity=Produit::class, inversedBy="declinations")
  24.      */
  25.     private $Produits;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=ValueDeclination::class, mappedBy="declination")
  28.      * @ORM\OrderBy({"name" = "ASC"})
  29.      */
  30.     private $valueDeclinations;
  31.     /**
  32.      * @ORM\Column(type="integer", nullable=true)
  33.      */
  34.     private $position;
  35.     public function __construct()
  36.     {
  37.         $this->Produits = new ArrayCollection();
  38.         $this->valueDeclinations = new ArrayCollection();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(string $name): self
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection|Produit[]
  55.      */
  56.     public function getProduits(): Collection
  57.     {
  58.         return $this->Produits;
  59.     }
  60.     public function addProduit(Produit $produit): self
  61.     {
  62.         if (!$this->Produits->contains($produit)) {
  63.             $this->Produits[] = $produit;
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeProduit(Produit $produit): self
  68.     {
  69.         $this->Produits->removeElement($produit);
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection|ValueDeclination[]
  74.      */
  75.     public function getValueDeclinations(): Collection
  76.     {
  77.         return $this->valueDeclinations;
  78.     }
  79.     public function addValueDeclination(ValueDeclination $valueDeclination): self
  80.     {
  81.         if (!$this->valueDeclinations->contains($valueDeclination)) {
  82.             $this->valueDeclinations[] = $valueDeclination;
  83.             $valueDeclination->setDeclination($this);
  84.         }
  85.         return $this;
  86.     }
  87.     public function removeValueDeclination(ValueDeclination $valueDeclination): self
  88.     {
  89.         if ($this->valueDeclinations->removeElement($valueDeclination)) {
  90.             // set the owning side to null (unless already changed)
  91.             if ($valueDeclination->getDeclination() === $this) {
  92.                 $valueDeclination->setDeclination(null);
  93.             }
  94.         }
  95.         return $this;
  96.     }
  97.     public function getPosition(): ?int
  98.     {
  99.         return $this->position;
  100.     }
  101.     public function setPosition(?int $position): self
  102.     {
  103.         $this->position $position;
  104.         return $this;
  105.     }
  106. }