src/Entity/ItemSpec.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\CommonTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\ItemSpecRepository")
  10.  * @ORM\Table(name="itm_spec")
  11.  * @UniqueEntity({"uuid"})
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class ItemSpec
  15. {
  16.     use CommonTrait;
  17.     /**
  18.      * @ORM\Column(type="string", length=255, nullable=true)
  19.      */
  20.     private $value;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity=ItemSpecTypes::class, inversedBy="itemSpecValues", cascade={"persist"})
  23.      * @ORM\JoinColumn(nullable=false)
  24.      */
  25.     private $itemSpecType;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $hiddenValue;
  30.     /**
  31.      * @ORM\Column(type="boolean", nullable=true)
  32.      */
  33.     private $isTop;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=ItemSpecTypes::class, inversedBy="parentSpec", cascade={"persist"})
  36.      */
  37.     private $childSpecType;
  38.     public function getValue(): ?string
  39.     {
  40.         return $this->value;
  41.     }
  42.     public function setValue(string $value): self
  43.     {
  44.         $this->value $value;
  45.         return $this;
  46.     }
  47.     public function getItemSpecType(): ?ItemSpecTypes
  48.     {
  49.         return $this->itemSpecType;
  50.     }
  51.     public function setItemSpecType(?ItemSpecTypes $itemSpecType): self
  52.     {
  53.         $this->itemSpecType $itemSpecType;
  54.         return $this;
  55.     }
  56.     public function __toString()
  57.     {
  58.         return $this->value;
  59.     }
  60.     public function getHiddenValue(): ?string
  61.     {
  62.         return $this->hiddenValue;
  63.     }
  64.     public function setHiddenValue(?string $hiddenValue): self
  65.     {
  66.         $this->hiddenValue $hiddenValue;
  67.         return $this;
  68.     }
  69.     public function getSpecValue()
  70.     {
  71.         if($this->hiddenValue) {
  72.             return $this->getItemSpecType()->getViewPrefix() . ' ' $this->hiddenValue ' ' $this->getItemSpecType()->getViewSuffix();
  73.         }
  74.         if($this->value) {
  75.             return $this->getItemSpecType()->getViewPrefix() . ' ' $this->value ' ' $this->getItemSpecType()->getViewSuffix();
  76.         }
  77.         return '';
  78.     }
  79.     public function getChildSpecType(): ?ItemSpecTypes
  80.     {
  81.         return $this->childSpecType;
  82.     }
  83.     public function setChildSpecType(?ItemSpecTypes $childSpecType): self
  84.     {
  85.         if(!$childSpecType) {
  86.             return $this;
  87.         }
  88.         $childSpecType->setParentSpec($this);
  89.         $this->childSpecType $childSpecType;
  90.         return $this;
  91.     }
  92.     public function getIsTop(): ?bool
  93.     {
  94.         return $this->isTop;
  95.     }
  96.     public function setIsTop(?bool $isTop): self
  97.     {
  98.         $this->isTop $isTop;
  99.         return $this;
  100.     }
  101. }