src/Entity/CompareParameter.php line 25

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 Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. /**
  15.  * @Doctrine\ORM\Mapping\Entity
  16.  * @Doctrine\ORM\Mapping\Table(name="compare_parameter")
  17.  * @Doctrine\ORM\Mapping\Entity()
  18.  */
  19. class CompareParameter implements TranslatableInterfaceBlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  20.     use BlameableTrait;
  21.     use TimestampableTrait;
  22.     use TranslatableTrait;
  23.     use SoftDeletableTrait;
  24.     
  25.     
  26.     
  27.     /**
  28.      * @var integer
  29.      *
  30.      * @ORM\Column(name="id", type="integer", nullable=false)
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue(strategy="IDENTITY")
  33.      */
  34.     private $id;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity="App\Entity\Category", cascade={"all"}, inversedBy="compareParameters")
  37.      * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
  38.      */
  39.     protected $category;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity="App\Entity\CompareParameterValue", mappedBy="parameter", cascade={"all"})
  42.      */
  43.     protected $values;
  44.     
  45.     
  46.     public function __construct()
  47.     {
  48.         $this->values = new ArrayCollection();
  49.     }
  50.     /**
  51.      * Obsługa tłumaczeń
  52.      * @param $method
  53.      * @param $arguments
  54.      * @return mixed
  55.      */
  56.     public function __call($method$arguments)
  57.     {
  58.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  59.     }
  60.     public function getName(){
  61.         return $this->translate()->getName();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getCategory(): ?Category
  68.     {
  69.         return $this->category;
  70.     }
  71.     public function setCategory(?Category $category): self
  72.     {
  73.         $this->category $category;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return Collection|CompareParameterValue[]
  78.      */
  79.     public function getValues(): Collection
  80.     {
  81.         return $this->values;
  82.     }
  83.     public function addValue(CompareParameterValue $value): self
  84.     {
  85.         if (!$this->values->contains($value)) {
  86.             $this->values[] = $value;
  87.             $value->setParameter($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeValue(CompareParameterValue $value): self
  92.     {
  93.         if ($this->values->contains($value)) {
  94.             $this->values->removeElement($value);
  95.             // set the owning side to null (unless already changed)
  96.             if ($value->getParameter() === $this) {
  97.                 $value->setParameter(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102. }