<?php
namespace App\Entity;
use App\Repository\ClassificationRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Gedmo\Translatable\Translatable;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Serializer\Annotation\Ignore;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Translation\ClassificationTranslation;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ClassificationRepository::class)
* @Gedmo\TranslationEntity(class="App\Entity\Translation\ClassificationTranslation")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @Vich\Uploadable
*/
class Classification implements Translatable
{
use TimestampableEntity;
use SetTranslationsTrait;
public const FIELDS = [
'title'
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("classification:list", "classification:item")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Translatable
* @Groups("classification:list", "classification:item")
*/
private $title;
/**
* @var string
* @Ignore()
*/
private $titleEn;
/**
* @var string
* @Ignore()
*/
private $titleCa;
/**
* @Assert\File(
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
* mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
* )
* @Vich\UploadableField(mapping="result_image", fileNameProperty="imageName", size="imageSize")
* @var File|null
* @Ignore()
*/
private $imageFile;
/**
* @ORM\Column(type="string")
*
* @var string|null
* @Groups("result:list", "result:item")
*/
private $imageName;
/**
* @ORM\Column(type="integer")
*
* @var int|null
*/
private $imageSize;
/**
* @Assert\File(
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
* mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
* )
* @Vich\UploadableField(mapping="result_image", fileNameProperty="imageNameEn", size="imageSizeEn")
* @var File|null
* @Ignore()
*/
private $imageFileEn;
/**
* @ORM\Column(type="string", nullable=true)
*
* @var string|null
* @Groups("result:list", "result:item")
*/
private $imageNameEn = null;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $imageSizeEn = null;
/**
* @Assert\File(
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
* mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
* )
* @Vich\UploadableField(mapping="result_image", fileNameProperty="imageNameCa", size="imageSizeCa")
* @var File|null
* @Ignore()
*/
private $imageFileCa;
/**
* @ORM\Column(type="string", nullable=true)
*
* @var string|null
* @Groups("result:list", "result:item")
*/
private $imageNameCa = null;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $imageSizeCa = null;
/**
* @ORM\OneToMany(
* targetEntity="App\Entity\Translation\ClassificationTranslation",
* mappedBy="object",
* cascade={"persist", "remove"}
* )
* @Ignore()
*/
private $translations;
/**
* @Gedmo\Locale
* Used locale to override Translation listener`s locale
* this is not a mapped field of entity metadata, just a simple property
*/
private $locale;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime|null
*/
protected $deletedAt;
/**
* Set or clear the deleted at timestamp.
*
* @return self
*/
public function setDeletedAt(\DateTime $deletedAt = null)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get the deleted at timestamp value. Will return null if
* the entity has not been soft deleted.
*
* @return \DateTime|null
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
/**
* @Assert\File(
* mimeTypes = {"application/pdf", "application/x-pdf"},
* mimeTypesMessage = "Please upload a valid PDF"
* )
* @Vich\UploadableField(mapping="classification", fileNameProperty="pdfName", size="pdfSize")
* @var File|null
* @Ignore()
*/
private $pdfFile;
/**
* Classification constructor.
*/
public function __construct()
{
$this->translations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return mixed
*/
public function getTitleEn()
{
return $this->titleEn;
}
/**
* @param string|null $titleEn
*
* @return $this
*/
public function setTitleEn(?string $titleEn): self
{
$this->titleEn = $titleEn;
return $this;
}
/**
* @return mixed
*/
public function getTitleCa()
{
return $this->titleCa;
}
/**
* @param string|null $titleCa
*
* @return $this
*/
public function setTitleCa(?string $titleCa): self
{
$this->titleCa = $titleCa;
return $this;
}
/**
* @param File|UploadedFile|null $pdfFile
*/
public function setPdfFile(?File $pdfFile = null): void
{
$this->pdfFile = $pdfFile;
if (null !== $pdfFile) {
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getPdfFile(): ?File
{
return $this->pdfFile;
}
/**
* @ORM\Column(type="string", nullable=true)
*
* @var string|null
* @Groups("classification:list", "classification:item")
*/
private $pdfName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $pdfSize;
public function setPdfName(?string $pdfName): void
{
$this->pdfName = $pdfName;
}
public function getPdfName(): ?string
{
return $this->pdfName;
}
public function setPdfSize(?int $pdfSize): void
{
$this->pdfSize = $pdfSize;
}
public function getPdfSize(): ?int
{
return $this->pdfSize;
}
public function getTranslations()
{
return $this->translations;
}
public function addTranslation(ClassificationTranslation $t)
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
}
/**
* @param File|UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function setImageName(?string $imageName): void
{
$this->imageName = $imageName;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageSize(?int $imageSize): void
{
$this->imageSize = $imageSize;
}
public function getImageSize(): ?int
{
return $this->imageSize;
}
/**
* @param File|UploadedFile|null $imageFileEn
*/
public function setImageFileEn(?File $imageFileEn = null): void
{
$this->imageFileEn = $imageFileEn;
if (null !== $imageFileEn) {
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFileEn(): ?File
{
return $this->imageFileEn;
}
public function setImageNameEn(?string $imageNameEn): void
{
$this->imageNameEn = $imageNameEn;
}
public function getImageNameEn(): ?string
{
return $this->imageNameEn;
}
public function setImageSizeEn(?int $imageSizeEn): void
{
$this->imageSizeEn = $imageSizeEn;
}
public function getImageSizeEn(): ?int
{
return $this->imageSizeEn;
}
/**
* @param File|UploadedFile|null $imageFileCa
*/
public function setImageFileCa(?File $imageFileCa = null): void
{
$this->imageFileCa = $imageFileCa;
if (null !== $imageFileCa) {
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFileCa(): ?File
{
return $this->imageFileCa;
}
public function setImageNameCa(?string $imageNameCa): void
{
$this->imageNameCa = $imageNameCa;
}
public function getImageNameCa(): ?string
{
return $this->imageNameCa;
}
public function setImageSizeCa(?int $imageSizeCa): void
{
$this->imageSizeCa = $imageSizeCa;
}
public function getImageSizeCa(): ?int
{
return $this->imageSizeCa;
}
}