src/Entity/Boisson.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BoissonRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=BoissonRepository::class)
  9.  */
  10. class Boisson
  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 $type;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=Cuvee::class, mappedBy="type_boisson")
  24.      */
  25.     private $cuvees;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=Boisson::class, inversedBy="sous_categories")
  28.      */
  29.     private $parent;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=Boisson::class, mappedBy="parent")
  32.      */
  33.     private $sous_categories;
  34.     public function __construct()
  35.     {
  36.         $this->cuvees = new ArrayCollection();
  37.         $this->sous_categories = new ArrayCollection();
  38.     }
  39.     public function __toString()
  40.     {
  41.         return $this->type;
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getType(): ?string
  48.     {
  49.         return $this->type;
  50.     }
  51.     public function setType(string $type): self
  52.     {
  53.         $this->type $type;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection<int, Cuvee>
  58.      */
  59.     public function getCuvees(): Collection
  60.     {
  61.         return $this->cuvees;
  62.     }
  63.     public function addCuvee(Cuvee $cuvee): self
  64.     {
  65.         if (!$this->cuvees->contains($cuvee)) {
  66.             $this->cuvees[] = $cuvee;
  67.             $cuvee->setTypeBoisson($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeCuvee(Cuvee $cuvee): self
  72.     {
  73.         if ($this->cuvees->removeElement($cuvee)) {
  74.             // set the owning side to null (unless already changed)
  75.             if ($cuvee->getTypeBoisson() === $this) {
  76.                 $cuvee->setTypeBoisson(null);
  77.             }
  78.         }
  79.         return $this;
  80.     }
  81.     public function getParent(): ?self
  82.     {
  83.         return $this->parent;
  84.     }
  85.     public function setParent(?self $parent): self
  86.     {
  87.         $this->parent $parent;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection<int, self>
  92.      */
  93.     public function getSousCategories(): Collection
  94.     {
  95.         return $this->sous_categories;
  96.     }
  97.     public function addSousCategory(self $sousCategory): self
  98.     {
  99.         if (!$this->sous_categories->contains($sousCategory)) {
  100.             $this->sous_categories[] = $sousCategory;
  101.             $sousCategory->setParent($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeSousCategory(self $sousCategory): self
  106.     {
  107.         if ($this->sous_categories->removeElement($sousCategory)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($sousCategory->getParent() === $this) {
  110.                 $sousCategory->setParent(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115. }