<?php
namespace App\Entity;
use App\Repository\SettingRepository;
use App\Traits\DateTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\SerializedName;
/**
* @ORM\Entity(repositoryClass=SettingRepository::class)
*
* @Serializer\ExclusionPolicy ("ALL")
*/
class Setting
{
use DateTrait;
/**
* Identifiant de l'entité
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups ({"setting"})
*/
private ?int $id = NULL;
/**
* Nom du paramètre
*
* @ORM\Column(type="string", length=255, unique=true)
*
* @Expose
* @Groups ({"setting"})
*/
private ?string $name = NULL;
/**
* Valeur du paramètre
*
* @ORM\Column(type="text", nullable=true)
*
* @Expose
* @Groups ({"setting"})
*/
private ?string $value = NULL;
/**
* Description du paramètre
*
* @ORM\Column(type="text")
*
* @Expose
* @Groups ({"setting"})
*/
private ?string $description = NULL;
/**
* Type de champ
*
* @ORM\Column(type="string", length=30)
*/
private ?string $fieldType = NULL;
/**
* Titre du paramètre
*
* @ORM\Column(type="string", length=128, nullable=true)
*
* @Expose
* @Groups ({"setting"})
*/
private ?string $title = NULL;
/**
* @ORM\OneToMany(targetEntity=Catalogue::class, mappedBy="settingCatalogue", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $catalogues;
/**
* @ORM\OneToMany(targetEntity=QuotasProductOrder::class, mappedBy="setting", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $quotasProductOrders;
public function __construct()
{
$this->catalogues = new ArrayCollection();
$this->quotasProductOrders = new ArrayCollection();
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("title_description")
* @Groups ({"setting"})
*
* @return array
*/
public function getNameDescription()
{
return [$this->title, $this->description];
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(?string $value): self
{
$this->value = $value;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getFieldType(): ?string
{
return $this->fieldType;
}
public function setFieldType(string $fieldType): self
{
$this->fieldType = $fieldType;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection<int, Catalogue>
*/
public function getCatalogues(): Collection
{
return $this->catalogues;
}
public function addCatalogue(Catalogue $catalogue): self
{
if (!$this->catalogues->contains($catalogue)) {
$this->catalogues[] = $catalogue;
$catalogue->setSettingCatalogue($this);
}
return $this;
}
public function removeCatalogue(Catalogue $catalogue): self
{
if ($this->catalogues->removeElement($catalogue)) {
// set the owning side to null (unless already changed)
if ($catalogue->getSettingCatalogue() === $this) {
$catalogue->setSettingCatalogue(null);
}
}
return $this;
}
/**
* @return Collection<int, QuotasProductOrder>
*/
public function getQuotasProductOrders(): Collection
{
return $this->quotasProductOrders;
}
public function addQuotasProductOrder(QuotasProductOrder $quotasProductOrder): self
{
if (!$this->quotasProductOrders->contains($quotasProductOrder)) {
$this->quotasProductOrders[] = $quotasProductOrder;
$quotasProductOrder->setSetting($this);
}
return $this;
}
public function removeQuotasProductOrder(QuotasProductOrder $quotasProductOrder): self
{
if ($this->quotasProductOrders->removeElement($quotasProductOrder)) {
// set the owning side to null (unless already changed)
if ($quotasProductOrder->getSetting() === $this) {
$quotasProductOrder->setSetting(null);
}
}
return $this;
}
}