src/Entity/OptionSelect.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\AbstractOption;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Entity\Trait\TranslatableLocale;
  6. use App\Repository\OptionSelectRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Gedmo\Translatable\Translatable;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. /**
  12.  * @ORM\Entity(repositoryClass=OptionSelectRepository::class)
  13.  */
  14. class OptionSelect extends AbstractOption
  15. {
  16.     use TranslatableLocale;
  17.   
  18.     /**
  19.      * @ORM\OneToMany(targetEntity=OptionSelectItem::class, mappedBy="optionSelect", orphanRemoval=true, cascade={"persist"})
  20.      */
  21.     private $optionSelectItems;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Extra::class, inversedBy="optionSelects")
  24.      * @ORM\JoinColumn(nullable=false)
  25.      */
  26.     private $extra;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=OptionSelectReservation::class, mappedBy="optionSelect")
  29.      */
  30.     private $optionSelectReservations;
  31.     public function __construct()
  32.     {
  33.         $this->optionSelectItems = new ArrayCollection();
  34.         $this->optionSelectReservations = new ArrayCollection();
  35.     }
  36.     /**
  37.      * @return Collection<int, OptionSelectItem>
  38.      */
  39.     public function getOptionSelectItems(): Collection
  40.     {
  41.         return $this->optionSelectItems;
  42.     }
  43.     public function addOptionSelectItem(OptionSelectItem $optionSelectItem): self
  44.     {
  45.         if (!$this->optionSelectItems->contains($optionSelectItem)) {
  46.             $this->optionSelectItems[] = $optionSelectItem;
  47.             $optionSelectItem->setOptionSelect($this);
  48.         }
  49.         return $this;
  50.     }
  51.     public function removeOptionSelectItem(OptionSelectItem $optionSelectItem): self
  52.     {
  53.         if ($this->optionSelectItems->removeElement($optionSelectItem)) {
  54.             // set the owning side to null (unless already changed)
  55.             if ($optionSelectItem->getOptionSelect() === $this) {
  56.                 $optionSelectItem->setOptionSelect(null);
  57.             }
  58.         }
  59.         return $this;
  60.     }
  61.     public function getExtra(): ?Extra
  62.     {
  63.         return $this->extra;
  64.     }
  65.     public function setExtra(?Extra $extra): self
  66.     {
  67.         $this->extra $extra;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection<int, OptionSelectReservation>
  72.      */
  73.     public function getOptionSelectReservations(): Collection
  74.     {
  75.         return $this->optionSelectReservations;
  76.     }
  77.     public function addOptionSelectReservation(OptionSelectReservation $optionSelectReservation): self
  78.     {
  79.         if (!$this->optionSelectReservations->contains($optionSelectReservation)) {
  80.             $this->optionSelectReservations[] = $optionSelectReservation;
  81.             $optionSelectReservation->setOptionSelect($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeOptionSelectReservation(OptionSelectReservation $optionSelectReservation): self
  86.     {
  87.         if ($this->optionSelectReservations->removeElement($optionSelectReservation)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($optionSelectReservation->getOptionSelect() === $this) {
  90.                 $optionSelectReservation->setOptionSelect(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     public function getEntitiesToRefresh(): array
  96.     {
  97.         $entitiesToRefresh = [];
  98.         $entitiesToRefresh[] = $this;
  99.         foreach($this->getOptionSelectItems() as $optionSelectItem) {
  100.             $entitiesToRefresh array_merge($entitiesToRefresh$optionSelectItem->getEntitiesToRefresh());
  101.         }
  102.         return $entitiesToRefresh;
  103.     }
  104. }