src/Entity/ProductParameterValue.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 Symfony\Contracts\Translation\TranslatorInterface;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\HttpFoundation\File\File;
  14. /**
  15.  * @Doctrine\ORM\Mapping\Entity
  16.  * @Doctrine\ORM\Mapping\Table(name="product_parameter_value")
  17.  */
  18. class ProductParameterValue implements TranslatableInterfaceBlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  19.     use BlameableTrait;
  20.     use TimestampableTrait;
  21.     use TranslatableTrait;
  22.     use SoftDeletableTrait;
  23.     
  24.     
  25.     
  26.     /**
  27.      * @Doctrine\ORM\Mapping\Id
  28.      * @Doctrine\ORM\Mapping\Column(type="integer")
  29.      * @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
  30.      */
  31.     protected $id;
  32.     /**
  33.      * @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\ProductParameter", inversedBy="values")
  34.      */
  35.     private $parameter;
  36.     /**
  37.      * @ORM\Column(type="string", length=255, nullable=true)
  38.      */
  39.     protected $value;
  40.     /**
  41.      * @Doctrine\ORM\Mapping\ManyToOne(targetEntity="ProductParameterValueGroup", inversedBy="values")
  42.      */
  43.     private $group;
  44.     /**
  45.      * @Doctrine\ORM\Mapping\Column(name="cart", type="boolean", options={"default"=0}, nullable=true)
  46.      */
  47.     protected $cart;
  48.     /**
  49.      * @Doctrine\ORM\Mapping\Column(name="short_description", type="boolean", options={"default"=0}, nullable=true)
  50.      */
  51.     protected $shortDescription;
  52.     /**
  53.      * @Doctrine\ORM\Mapping\Column(name="visible", type="boolean", options={"default"=1}, nullable=true)
  54.      */
  55.     protected $visible;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     protected $path;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     protected $photo3d;
  64.     /**
  65.      * @return mixed
  66.      */
  67.     public function getShortDescription()
  68.     {
  69.         return $this->shortDescription;
  70.     }
  71.     /**
  72.      * @param mixed $shortDescription
  73.      */
  74.     public function setShortDescription($shortDescription): void
  75.     {
  76.         $this->shortDescription $shortDescription;
  77.     }
  78.     public function customTrans($params$idCompare) {
  79.         return array_filter($params, function($e) use ($idCompare) {
  80.             return (isset($e['id'])) && $e['id'] == $idCompare;
  81.         });
  82.     }
  83.     
  84.     public function __call($method$arguments)
  85.     {
  86.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  87.     }
  88.     public function getName()
  89.     {
  90.         return $this->translate()->getName();
  91.     }
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     public function getParameter(): ?ProductParameter
  97.     {
  98.         return $this->parameter;
  99.     }
  100.     public function setParameter(?ProductParameter $parameter): self
  101.     {
  102.         $this->parameter $parameter;
  103.         return $this;
  104.     }
  105.     public function getPath(): ?string
  106.     {
  107.         return $this->path;
  108.     }
  109.     public function setPath(?string $path): self
  110.     {
  111.         $this->path $path;
  112.         return $this;
  113.     }
  114.     public function getPhoto3d(): ?string
  115.     {
  116.         return $this->photo3d;
  117.     }
  118.     public function setPhoto3d(?string $photo3d): self
  119.     {
  120.         $this->photo3d $photo3d;
  121.         return $this;
  122.     }
  123.     public function getGroup(): ?ProductParameterValueGroup
  124.     {
  125.         return $this->group;
  126.     }
  127.     public function setGroup(?ProductParameterValueGroup $group): self
  128.     {
  129.         $this->group $group;
  130.         return $this;
  131.     }
  132.     /**
  133.      *
  134.      * note This is not a mapped field of entity metadata, just a simple property.
  135.      *
  136.      * @var File $imageFile
  137.      */
  138.     protected $imageFile;
  139.     /**
  140.      * @ORM\Column(type="string", length=255, name="image_name", nullable=true)
  141.      * @var string $imageName
  142.      */
  143.     protected $imageName;
  144.     public function setImageFile(File $image null)
  145.     {
  146.         $this->imageFile $image;
  147.         if ($image) {
  148.             $fileName md5(uniqid()).'.'.$image->guessExtension();
  149.             // Move the file to the directory where brochures are stored
  150.             $brochuresDir getcwd().'/images/parameters/';
  151.             $image->move($brochuresDir$fileName);
  152.             // Update the 'brochure' property to store the PDF file name
  153.             // instead of its contents
  154.             $this->setImageName($fileName);
  155.             $this->updatedAt = new \DateTime('now');
  156.         }
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return File
  161.      */
  162.     public function getImageFile()
  163.     {
  164.         return $this->imageFile;
  165.     }
  166.     /**
  167.      * @param string $imageName
  168.      */
  169.     public function setImageName($imageName)
  170.     {
  171.         $this->imageName $imageName;
  172.     }
  173.     /**
  174.      * @return string
  175.      */
  176.     public function getImageName()
  177.     {
  178.         return $this->imageName;
  179.     }
  180.     public function getCart(): ?bool
  181.     {
  182.         return $this->cart;
  183.     }
  184.     public function setCart(?bool $cart): self
  185.     {
  186.         $this->cart $cart;
  187.         return $this;
  188.     }
  189.     public function getVisible(): ?bool
  190.     {
  191.         return $this->visible;
  192.     }
  193.     public function setVisible(?bool $visible): self
  194.     {
  195.         $this->visible $visible;
  196.         return $this;
  197.     }
  198.     public function getValue(): ?string
  199.     {
  200.         return $this->value;
  201.     }
  202.     public function setValue(?string $value): self
  203.     {
  204.         $this->value $value;
  205.         return $this;
  206.     }
  207. }