src/Entity/ProductParameter.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  6. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  9. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  10. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  11. use App\Model\LangParamInterface;
  12. use App\Model\LangParamRelationInterface;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Symfony\Contracts\Translation\TranslatorInterface;
  16. use Doctrine\ORM\Mapping as ORM;
  17. /**
  18.  * @Doctrine\ORM\Mapping\Entity
  19.  * @Doctrine\ORM\Mapping\Table(name="product_parameter")
  20.  */
  21. class ProductParameter implements TranslatableInterfaceLangParamInterface
  22. BlameableInterfaceTimestampableInterfaceSoftDeletableInterface {
  23.     use BlameableTrait;
  24.     use TimestampableTrait;
  25.     use TranslatableTrait;
  26.     use SoftDeletableTrait;
  27.     
  28. const GROUP_ERGONOMY 'ergonomia';
  29.     const GROUP_FUNCTION 'funkcje';
  30.     const GROUP_EXECUTION 'wykonanie';
  31.     const CHOOSABLE_VERSIONS 8;
  32.     const CHOOSABLE_TEXTILE 9;
  33.     const CHOOSABLE_NET 55;
  34.     const CHOOSABLE_WOOD 23;
  35.     const CHOOSABLE_KOLATKA_PINEZKA 75;
  36.     const CHOOSABLE_WOOD_LEGS 76;
  37.     /**
  38.      * @return array
  39.      */
  40.     static public function getChoosableParameters() {
  41.         return [8,9,55,23,75,76];
  42.     }
  43.     static public function getSimpleGroups(TranslatorInterface $translator) {
  44.         return [
  45.             self::GROUP_ERGONOMY => $translator->trans(self::GROUP_ERGONOMY, [], 'admin'),
  46.             self::GROUP_FUNCTION => $translator->trans(self::GROUP_FUNCTION, [], 'admin'),
  47.             self::GROUP_EXECUTION => $translator->trans(self::GROUP_EXECUTION, [], 'admin')
  48.         ];
  49.     }
  50.     
  51.     
  52.     
  53.     /**
  54.      * @Doctrine\ORM\Mapping\Id
  55.      * @Doctrine\ORM\Mapping\Column(type="integer")
  56.      * @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
  57.      */
  58.     protected $id;
  59.     /**
  60.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductParameterValue", mappedBy="parameter", cascade={"all"})
  61.      * @Doctrine\ORM\Mapping\OrderBy({"id" = "DESC"})
  62.      */
  63.     protected $values;
  64.     /**
  65.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\ProductParameterValueGroup", mappedBy="parameter", cascade={"all"})
  66.      * @Doctrine\ORM\Mapping\OrderBy({"id" = "DESC"})
  67.      */
  68.     protected $groupValues;
  69.     /**
  70.      * @var boolean
  71.      *
  72.      * @Doctrine\ORM\Mapping\Column(name="is_filter", type="boolean", nullable=false)
  73.      */
  74.     private $filter;
  75.     /**
  76.      * @var boolean
  77.      *
  78.      * @Doctrine\ORM\Mapping\Column(name="choosable", type="boolean", nullable=false)
  79.      */
  80.     private $choosable;
  81.     /**
  82.      * @var string
  83.      *
  84.      * @Doctrine\ORM\Mapping\Column(name="group_name", type="text", nullable=true)
  85.      */
  86.     private $group;
  87.     /**
  88.      * @var boolean
  89.      *
  90.      * @Doctrine\ORM\Mapping\Column(name="simple", type="boolean", nullable=true)
  91.      */
  92.     private $simple;
  93.     /**
  94.      * @ORM\OneToMany(targetEntity="App\Entity\ProductParameterLangParam", mappedBy="productParameter", cascade={"all"})
  95.      */
  96.     protected $langParams;
  97.     /**
  98.      * Obsługa tłumaczeń
  99.      * @param $method
  100.      * @param $arguments
  101.      * @return mixed
  102.      */
  103.     public function __call($method$arguments)
  104.     {
  105.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  106.     }
  107.     public function getName()
  108.     {
  109.         return $this->translate()->getName();
  110.     }
  111.     
  112.     public function __construct()
  113.     {
  114.         $this->values = new ArrayCollection();
  115.         $this->groupValues = new ArrayCollection();
  116.         $this->langParams = new ArrayCollection();
  117.     }
  118.     public function getId(): ?int
  119.     {
  120.         return $this->id;
  121.     }
  122.     public function getFilter(): ?bool
  123.     {
  124.         return $this->filter;
  125.     }
  126.     public function setFilter(bool $filter): self
  127.     {
  128.         $this->filter $filter;
  129.         return $this;
  130.     }
  131.     public function getChoosable(): ?bool
  132.     {
  133.         return $this->choosable;
  134.     }
  135.     public function setChoosable(bool $choosable): self
  136.     {
  137.         $this->choosable $choosable;
  138.         return $this;
  139.     }
  140.     public function getGroup(): ?string
  141.     {
  142.         return $this->group;
  143.     }
  144.     public function setGroup(?string $group): self
  145.     {
  146.         $this->group $group;
  147.         return $this;
  148.     }
  149.     public function getSimple(): ?bool
  150.     {
  151.         return $this->simple;
  152.     }
  153.     public function setSimple(?bool $simple): self
  154.     {
  155.         $this->simple $simple;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection|ProductParameterValue[]
  160.      */
  161.     public function getValues(): Collection
  162.     {
  163.         return $this->values;
  164.     }
  165.     public function addValue(ProductParameterValue $value): self
  166.     {
  167.         if (!$this->values->contains($value)) {
  168.             $this->values[] = $value;
  169.             $value->setParameter($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeValue(ProductParameterValue $value): self
  174.     {
  175.         if ($this->values->contains($value)) {
  176.             $this->values->removeElement($value);
  177.             // set the owning side to null (unless already changed)
  178.             if ($value->getParameter() === $this) {
  179.                 $value->setParameter(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection|ProductParameterValueGroup[]
  186.      */
  187.     public function getGroupValues(): Collection
  188.     {
  189.         return $this->groupValues;
  190.     }
  191.     public function addGroupValue(ProductParameterValueGroup $groupValue): self
  192.     {
  193.         if (!$this->groupValues->contains($groupValue)) {
  194.             $this->groupValues[] = $groupValue;
  195.             $groupValue->setParameter($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeGroupValue(ProductParameterValueGroup $groupValue): self
  200.     {
  201.         if ($this->groupValues->contains($groupValue)) {
  202.             $this->groupValues->removeElement($groupValue);
  203.             // set the owning side to null (unless already changed)
  204.             if ($groupValue->getParameter() === $this) {
  205.                 $groupValue->setParameter(null);
  206.             }
  207.         }
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return Collection|ProductParameterLangParam[]
  212.      */
  213.     public function getLangParams(): Collection
  214.     {
  215.         return $this->langParams;
  216.     }
  217.     public function addLangParam(LangParamRelationInterface $langParam): self
  218.     {
  219.         if (!$this->langParams->contains($langParam)) {
  220.             $this->langParams[] = $langParam;
  221.             $langParam->setProductParameter($this);
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeLangParam(ProductParameterLangParam $langParam): self
  226.     {
  227.         if ($this->langParams->contains($langParam)) {
  228.             $this->langParams->removeElement($langParam);
  229.             // set the owning side to null (unless already changed)
  230.             if ($langParam->getProductParameter() === $this) {
  231.                 $langParam->setProductParameter(null);
  232.             }
  233.         }
  234.         return $this;
  235.     }
  236. }