<?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 Symfony\Contracts\Translation\TranslatorInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
/**
* @Doctrine\ORM\Mapping\Entity
* @Doctrine\ORM\Mapping\Table(name="product_parameter_value")
*/
class ProductParameterValue implements TranslatableInterface, BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use TranslatableTrait;
use SoftDeletableTrait;
/**
* @Doctrine\ORM\Mapping\Id
* @Doctrine\ORM\Mapping\Column(type="integer")
* @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\ProductParameter", inversedBy="values")
*/
private $parameter;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $value;
/**
* @Doctrine\ORM\Mapping\ManyToOne(targetEntity="ProductParameterValueGroup", inversedBy="values")
*/
private $group;
/**
* @Doctrine\ORM\Mapping\Column(name="cart", type="boolean", options={"default"=0}, nullable=true)
*/
protected $cart;
/**
* @Doctrine\ORM\Mapping\Column(name="short_description", type="boolean", options={"default"=0}, nullable=true)
*/
protected $shortDescription;
/**
* @Doctrine\ORM\Mapping\Column(name="visible", type="boolean", options={"default"=1}, nullable=true)
*/
protected $visible;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $path;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $photo3d;
/**
* @return mixed
*/
public function getShortDescription()
{
return $this->shortDescription;
}
/**
* @param mixed $shortDescription
*/
public function setShortDescription($shortDescription): void
{
$this->shortDescription = $shortDescription;
}
public function customTrans($params, $idCompare) {
return array_filter($params, function($e) use ($idCompare) {
return (isset($e['id'])) && $e['id'] == $idCompare;
});
}
public function __call($method, $arguments)
{
return $this->proxyCurrentLocaleTranslation($method, $arguments);
}
public function getName()
{
return $this->translate()->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getParameter(): ?ProductParameter
{
return $this->parameter;
}
public function setParameter(?ProductParameter $parameter): self
{
$this->parameter = $parameter;
return $this;
}
public function getPath(): ?string
{
return $this->path;
}
public function setPath(?string $path): self
{
$this->path = $path;
return $this;
}
public function getPhoto3d(): ?string
{
return $this->photo3d;
}
public function setPhoto3d(?string $photo3d): self
{
$this->photo3d = $photo3d;
return $this;
}
public function getGroup(): ?ProductParameterValueGroup
{
return $this->group;
}
public function setGroup(?ProductParameterValueGroup $group): self
{
$this->group = $group;
return $this;
}
/**
*
* note This is not a mapped field of entity metadata, just a simple property.
*
* @var File $imageFile
*/
protected $imageFile;
/**
* @ORM\Column(type="string", length=255, name="image_name", nullable=true)
* @var string $imageName
*/
protected $imageName;
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
$fileName = md5(uniqid()).'.'.$image->guessExtension();
// Move the file to the directory where brochures are stored
$brochuresDir = getcwd().'/images/parameters/';
$image->move($brochuresDir, $fileName);
// Update the 'brochure' property to store the PDF file name
// instead of its contents
$this->setImageName($fileName);
$this->updatedAt = new \DateTime('now');
}
return $this;
}
/**
* @return File
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param string $imageName
*/
public function setImageName($imageName)
{
$this->imageName = $imageName;
}
/**
* @return string
*/
public function getImageName()
{
return $this->imageName;
}
public function getCart(): ?bool
{
return $this->cart;
}
public function setCart(?bool $cart): self
{
$this->cart = $cart;
return $this;
}
public function getVisible(): ?bool
{
return $this->visible;
}
public function setVisible(?bool $visible): self
{
$this->visible = $visible;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(?string $value): self
{
$this->value = $value;
return $this;
}
}