<?php
namespace App\Entity;
use App\Repository\PageBlockCarouselItemRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=PageBlockCarouselItemRepository::class)
* @Vich\Uploadable
*/
class PageBlockCarouselItem
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $text;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imageName;
/**
* @Assert\File(
* maxSize = "10M",
* mimeTypes = {"image/jpeg", "image/png", "image/bmp"},
* )
* @Vich\UploadableField(mapping="home_pageblock_carousel", fileNameProperty="imageName")
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
*/
private $updatedAt;
public function __construct()
{
$this->updatedAt = new \DateTime();
}
/**
* @ORM\ManyToOne(targetEntity=PageBlockCarousel::class, inversedBy="items")
* @ORM\JoinColumn(nullable=false)
*/
private $pageBlockCarousel;
public function getId(): ?int
{
return $this->id;
}
public function getPageBlockCarousel(): ?PageBlockCarousel
{
return $this->pageBlockCarousel;
}
public function setPageBlockCarousel(?PageBlockCarousel $pageBlockCarousel): self
{
$this->pageBlockCarousel = $pageBlockCarousel;
return $this;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(?string $text): self
{
$this->text = $text;
return $this;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageName(?string $imageName): PageBlockCarouselItem
{
$this->imageName = $imageName;
return $this;
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File|null $image
*/
public function setImageFile(File $image = null)
{
$this->imageFile = $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
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
}