<?php
namespace App\Entity;
use App\Repository\GalleryRepository;
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\Groups;
use Symfony\Component\Serializer\Annotation\Ignore;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Translation\GalleryTranslation;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=GalleryRepository::class)
* @Gedmo\TranslationEntity(class="App\Entity\Translation\GalleryTranslation")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @Vich\Uploadable
*/
class Gallery implements Translatable
{
use TimestampableEntity;
use SetTranslationsTrait;
public const FIELDS = [
'title',
'description'
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("gallery:list", "banner:list", "banner:item")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Translatable
* @Groups("gallery:list", "banner:list", "banner:item")
*/
private $title;
/**
* @var string
* @Ignore()
*/
private $titleEn;
/**
* @var string
* @Ignore()
*/
private $titleCa;
/**
* @ORM\Column(type="text")
* @Groups("gallery:list", "banner:list", "banner:item")
*/
private $description;
/**
* @var string
* @Ignore()
*/
private $descriptionEn;
/**
* @var string
* @Ignore()
*/
private $descriptionCa;
/**
* @ORM\Column(type="date")
* @Groups("gallery:list", "banner:list", "banner:item")
*/
private $date;
/**
* @ORM\Column(type="string")
*
* @var string|null
* @Groups("gallery:list", "banner:list", "banner:item")
*/
private $imageName;
/**
* @ORM\Column(type="integer")
*
* @var int|null
* @Ignore()
*/
private $imageSize;
/**
* @ORM\OneToMany(
* targetEntity="App\Entity\Translation\GalleryTranslation",
* mappedBy="object",
* cascade={"persist", "remove"}
* )
* @Ignore()
*/
private $translations;
/**
* @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;
}
/**
* Gallery 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 string |null
*/
public function getTitleEn(): ?string
{
return $this->titleEn;
}
/**
* @param string|null $titleEn
*
* @return $this
*/
public function setTitleEn(?string $titleEn): self
{
$this->titleEn = $titleEn;
return $this;
}
/**
* @return string |null
*/
public function getTitleCa(): ?string
{
return $this->titleCa;
}
/**
* @param string|null $titleCa
*
* @return $this
*/
public function setTitleCa(?string $titleCa): self
{
$this->titleCa = $titleCa;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
/**
* @Gedmo\Locale
*/
private $locale;
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
/**
* @Assert\File(
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
* mimeTypesMessage = "Wrong file type (jpeg,gif,png,jpg)"
* )
* @Vich\UploadableField(mapping="gallery", fileNameProperty="imageName", size="imageSize")
* @var File|null
* @Ignore()
*/
private $imageFile;
/**
* @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;
}
public function getTranslations()
{
return $this->translations;
}
public function addTranslation(GalleryTranslation $t)
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
}
/**
* @return string|null
*/
public function getDescriptionCa(): ?string
{
return $this->descriptionCa;
}
/**
* @param string|null $descriptionCa
*/
public function setDescriptionCa(?string $descriptionCa): void
{
$this->descriptionCa = $descriptionCa;
}
/**
* @return string |null
*/
public function getDescriptionEn(): ?string
{
return $this->descriptionEn;
}
/**
* @param string|null $descriptionEn
*/
public function setDescriptionEn(?string $descriptionEn): void
{
$this->descriptionEn = $descriptionEn;
}
}