<?php
namespace App\Entity;
use App\Entity\Traits\CommonTrait;
use App\Repository\PageSliderSlideRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Entity\File as EmbeddedFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Entity(repositoryClass=PageSliderSlideRepository::class)
* @ORM\Table(name="app_page_slider_slide")
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity({"uuid"})
*/
#[Vich\Uploadable]
class PageSliderSlide
{
use CommonTrait;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity=PageSlider::class, inversedBy="slides")
*/
private $slider;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
*
* @var File|null
*/
#[Vich\UploadableField(mapping: 'slide', fileNameProperty: 'imageFile.name', size: 'imageFile.size', mimeType: 'imageFile.mimeType', originalName: 'imageFile.originalName', dimensions: 'imageFile.dimensions')]
private $image;
/**
* @ORM\Embedded(class="Vich\UploaderBundle\Entity\File")
*
* @var EmbeddedFile
*/
private $imageFile;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $textPosition;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $hrefTo;
public function __construct()
{
$this->imageFile = new EmbeddedFile();
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getSlider(): ?PageSlider
{
return $this->slider;
}
public function setSlider(?PageSlider $slider): self
{
$this->slider = $slider;
return $this;
}
public function setImage(?File $image = null)
{
$this->image = $image;
if (null !== $image) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImage(): ?File
{
return $this->image;
}
public function setImageFile(EmbeddedFile $image): void
{
$this->imageFile = $image;
}
public function getImageFile(): ?EmbeddedFile
{
return $this->imageFile;
}
public function getTextPosition(): ?int
{
return $this->textPosition;
}
public function setTextPosition(?int $textPosition): self
{
$this->textPosition = $textPosition;
return $this;
}
public function getHrefTo(): ?string
{
return $this->hrefTo;
}
public function setHrefTo(?string $link): self
{
$this->hrefTo = $link;
return $this;
}
}