<?php
namespace App\Entity;
use App\Entity\Trait\TranslatableLocale;
use App\Repository\ExtraRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
/**
* @ORM\Entity(repositoryClass=ExtraRepository::class)
*/
class Extra
{
use TranslatableLocale;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @Gedmo\Translatable
* @ORM\Column(type="string", length=255)
*/
private $label;
/**
* @Gedmo\Translatable
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="integer")
*/
private $price;
/**
* @Gedmo\Translatable
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $placeholderCommentary;
/**
* @ORM\Column(type="boolean")
*/
private $enablePrivatisation;
/**
* @ORM\Column(type="boolean")
*/
private $enableReservation;
/**
* @ORM\Column(type="boolean")
*/
private $enableCarteCadeau;
/**
* @ORM\OneToMany(targetEntity=OptionSelect::class, mappedBy="extra", orphanRemoval=true, cascade={"persist"})
*/
private $optionSelects;
/**
* @ORM\OneToMany(targetEntity=OptionQuantity::class, mappedBy="extra", orphanRemoval=true, cascade={"persist"})
*/
private $optionQuantities;
/**
* @ORM\OneToMany(targetEntity=ExtraReservation::class, mappedBy="extra")
*/
private $extraReservations;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $tvaRatio;
/**
* @ORM\Column(type="boolean")
*/
private $singleObject;
/**
* @Gedmo\Translatable
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $labelButtonAdd;
/**
* @var \DateTime $created
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime", nullable=true)
*/
private $created;
/**
* @var \DateTime $updated
*
* @Gedmo\Timestampable(on="update")
* @ORM\Column(type="datetime", nullable=true)
*/
private $updated;
public function __construct()
{
$this->optionSelects = new ArrayCollection();
$this->optionQuantities = new ArrayCollection();
$this->extraReservations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPrice(): ?float
{
return $this->price / 100;
}
public function setPrice(int $price): self
{
$this->price = $price;
return $this;
}
public function getPlaceholderCommentary(): ?string
{
return $this->placeholderCommentary;
}
public function setPlaceholderCommentary(?string $placeholderCommentary): self
{
$this->placeholderCommentary = $placeholderCommentary;
return $this;
}
public function isEnablePrivatisation(): ?bool
{
return $this->enablePrivatisation;
}
public function setEnablePrivatisation(bool $enablePrivatisation): self
{
$this->enablePrivatisation = $enablePrivatisation;
return $this;
}
public function isEnableReservation(): ?bool
{
return $this->enableReservation;
}
public function setEnableReservation(bool $enableReservation): self
{
$this->enableReservation = $enableReservation;
return $this;
}
/**
* @return Collection<int, OptionSelect>
*/
public function getOptionSelects(): Collection
{
return $this->optionSelects;
}
/**
* @return Collection<int, OptionSelect>
*/
public function getActiveOptionSelects(): Collection
{
return $this->optionSelects->filter(function(OptionSelect $optionSelect) {
return !$optionSelect->isDeleted();
});
}
public function addOptionSelect(OptionSelect $optionSelect): self
{
if (!$this->optionSelects->contains($optionSelect)) {
$this->optionSelects[] = $optionSelect;
$optionSelect->setExtra($this);
}
return $this;
}
public function removeOptionSelect(OptionSelect $optionSelect): self
{
if ($this->optionSelects->removeElement($optionSelect)) {
// set the owning side to null (unless already changed)
if ($optionSelect->getExtra() === $this) {
$optionSelect->setExtra(null);
}
}
return $this;
}
/**
* @return Collection<int, OptionQuantity>
*/
public function getOptionQuantities(): Collection
{
return $this->optionQuantities;
}
/**
* @return Collection<int, OptionQuantity>
*/
public function getActiveOptionQuantities(): Collection
{
return $this->optionQuantities->filter(function(OptionQuantity $optionQuantity) {
return !$optionQuantity->isDeleted();
});
}
public function addOptionQuantity(OptionQuantity $optionQuantity): self
{
if (!$this->optionQuantities->contains($optionQuantity)) {
$this->optionQuantities[] = $optionQuantity;
$optionQuantity->setExtra($this);
}
return $this;
}
public function removeOptionQuantity(OptionQuantity $optionQuantity): self
{
if ($this->optionQuantities->removeElement($optionQuantity)) {
// set the owning side to null (unless already changed)
if ($optionQuantity->getExtra() === $this) {
$optionQuantity->setExtra(null);
}
}
return $this;
}
/**
* @return Collection<int, ExtraReservation>
*/
public function getExtraReservations(): Collection
{
return $this->extraReservations;
}
public function addExtraReservation(ExtraReservation $extraReservation): self
{
if (!$this->extraReservations->contains($extraReservation)) {
$this->extraReservations[] = $extraReservation;
$extraReservation->setExtra($this);
}
return $this;
}
public function removeExtraReservation(ExtraReservation $extraReservation): self
{
if ($this->extraReservations->removeElement($extraReservation)) {
// set the owning side to null (unless already changed)
if ($extraReservation->getExtra() === $this) {
$extraReservation->setExtra(null);
}
}
return $this;
}
public function getTvaRatio(): ?float
{
return $this->tvaRatio;
}
public function setTvaRatio(?float $tvaRatio): self
{
$this->tvaRatio = $tvaRatio;
return $this;
}
public function isSingleObject(): ?bool
{
return $this->singleObject;
}
public function setSingleObject(bool $singleObject): self
{
$this->singleObject = $singleObject;
return $this;
}
public function getLabelButtonAdd(): ?string
{
return $this->labelButtonAdd;
}
public function setLabelButtonAdd(?string $labelButtonAdd): self
{
$this->labelButtonAdd = $labelButtonAdd;
return $this;
}
public function getEntitiesToRefresh(): array
{
$entitiesToRefresh = [];
$entitiesToRefresh[] = $this;
foreach($this->getOptionSelects() as $optionSelect) {
$entitiesToRefresh = array_merge($entitiesToRefresh, $optionSelect->getEntitiesToRefresh());
}
foreach($this->getOptionQuantities() as $optionQuantity) {
$entitiesToRefresh = array_merge($entitiesToRefresh, $optionQuantity->getEntitiesToRefresh());
}
return $entitiesToRefresh;
}
public function isEnableCarteCadeau(): ?bool
{
return $this->enableCarteCadeau;
}
public function setEnableCarteCadeau(?bool $enableCarteCadeau): self
{
$this->enableCarteCadeau = $enableCarteCadeau;
return $this;
}
}