<?php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use App\Model\LangParamInterface;
use App\Model\LangParamRelationInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Contracts\Translation\TranslatorInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @Doctrine\ORM\Mapping\Entity
* @Doctrine\ORM\Mapping\Table(name="product_parameter")
*/
class ProductParameter implements TranslatableInterface, LangParamInterface
, BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use TranslatableTrait;
use SoftDeletableTrait;
const GROUP_ERGONOMY = 'ergonomia';
const GROUP_FUNCTION = 'funkcje';
const GROUP_EXECUTION = 'wykonanie';
const CHOOSABLE_VERSIONS = 8;
const CHOOSABLE_TEXTILE = 9;
const CHOOSABLE_NET = 55;
const CHOOSABLE_WOOD = 23;
const CHOOSABLE_KOLATKA_PINEZKA = 75;
const CHOOSABLE_WOOD_LEGS = 76;
/**
* @return array
*/
static public function getChoosableParameters() {
return [8,9,55,23,75,76];
}
static public function getSimpleGroups(TranslatorInterface $translator) {
return [
self::GROUP_ERGONOMY => $translator->trans(self::GROUP_ERGONOMY, [], 'admin'),
self::GROUP_FUNCTION => $translator->trans(self::GROUP_FUNCTION, [], 'admin'),
self::GROUP_EXECUTION => $translator->trans(self::GROUP_EXECUTION, [], 'admin')
];
}
/**
* @Doctrine\ORM\Mapping\Id
* @Doctrine\ORM\Mapping\Column(type="integer")
* @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductParameterValue", mappedBy="parameter", cascade={"all"})
* @Doctrine\ORM\Mapping\OrderBy({"id" = "DESC"})
*/
protected $values;
/**
* @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductParameterValueGroup", mappedBy="parameter", cascade={"all"})
* @Doctrine\ORM\Mapping\OrderBy({"id" = "DESC"})
*/
protected $groupValues;
/**
* @var boolean
*
* @Doctrine\ORM\Mapping\Column(name="is_filter", type="boolean", nullable=false)
*/
private $filter;
/**
* @var boolean
*
* @Doctrine\ORM\Mapping\Column(name="choosable", type="boolean", nullable=false)
*/
private $choosable;
/**
* @var string
*
* @Doctrine\ORM\Mapping\Column(name="group_name", type="text", nullable=true)
*/
private $group;
/**
* @var boolean
*
* @Doctrine\ORM\Mapping\Column(name="simple", type="boolean", nullable=true)
*/
private $simple;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ProductParameterLangParam", mappedBy="productParameter", cascade={"all"})
*/
protected $langParams;
/**
* Obsługa tłumaczeń
* @param $method
* @param $arguments
* @return mixed
*/
public function __call($method, $arguments)
{
return $this->proxyCurrentLocaleTranslation($method, $arguments);
}
public function getName()
{
return $this->translate()->getName();
}
public function __construct()
{
$this->values = new ArrayCollection();
$this->groupValues = new ArrayCollection();
$this->langParams = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFilter(): ?bool
{
return $this->filter;
}
public function setFilter(bool $filter): self
{
$this->filter = $filter;
return $this;
}
public function getChoosable(): ?bool
{
return $this->choosable;
}
public function setChoosable(bool $choosable): self
{
$this->choosable = $choosable;
return $this;
}
public function getGroup(): ?string
{
return $this->group;
}
public function setGroup(?string $group): self
{
$this->group = $group;
return $this;
}
public function getSimple(): ?bool
{
return $this->simple;
}
public function setSimple(?bool $simple): self
{
$this->simple = $simple;
return $this;
}
/**
* @return Collection|ProductParameterValue[]
*/
public function getValues(): Collection
{
return $this->values;
}
public function addValue(ProductParameterValue $value): self
{
if (!$this->values->contains($value)) {
$this->values[] = $value;
$value->setParameter($this);
}
return $this;
}
public function removeValue(ProductParameterValue $value): self
{
if ($this->values->contains($value)) {
$this->values->removeElement($value);
// set the owning side to null (unless already changed)
if ($value->getParameter() === $this) {
$value->setParameter(null);
}
}
return $this;
}
/**
* @return Collection|ProductParameterValueGroup[]
*/
public function getGroupValues(): Collection
{
return $this->groupValues;
}
public function addGroupValue(ProductParameterValueGroup $groupValue): self
{
if (!$this->groupValues->contains($groupValue)) {
$this->groupValues[] = $groupValue;
$groupValue->setParameter($this);
}
return $this;
}
public function removeGroupValue(ProductParameterValueGroup $groupValue): self
{
if ($this->groupValues->contains($groupValue)) {
$this->groupValues->removeElement($groupValue);
// set the owning side to null (unless already changed)
if ($groupValue->getParameter() === $this) {
$groupValue->setParameter(null);
}
}
return $this;
}
/**
* @return Collection|ProductParameterLangParam[]
*/
public function getLangParams(): Collection
{
return $this->langParams;
}
public function addLangParam(LangParamRelationInterface $langParam): self
{
if (!$this->langParams->contains($langParam)) {
$this->langParams[] = $langParam;
$langParam->setProductParameter($this);
}
return $this;
}
public function removeLangParam(ProductParameterLangParam $langParam): self
{
if ($this->langParams->contains($langParam)) {
$this->langParams->removeElement($langParam);
// set the owning side to null (unless already changed)
if ($langParam->getProductParameter() === $this) {
$langParam->setProductParameter(null);
}
}
return $this;
}
}