<?php
namespace App\Entity;
use App\Repository\BlogPostGalleryItemRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=BlogPostGalleryItemRepository::class)
* @ORM\Entity
* @Vich\Uploadable
*/
class BlogPostGalleryItem
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=BlogPostGallery::class, inversedBy="items")
* @ORM\JoinColumn(nullable=false)
*/
private $gallery;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $mediaName;
/**
* @Assert\File(
* maxSize = "2048k",
* mimeTypes = {"image/jpeg", "image/png", "image/bmp", "video/mp4", "application/pdf"},
* )
* @Vich\UploadableField(mapping="home_pageblock_carousel", fileNameProperty="mediaName")
* @var File
*/
private $mediaFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
*/
private $updatedAt;
public function __construct()
{
$this->updatedAt = new \Datetime();
}
public function getId(): ?int
{
return $this->id;
}
public function getGallery(): ?BlogPostGallery
{
return $this->gallery;
}
public function setGallery(?BlogPostGallery $gallery): self
{
$this->gallery = $gallery;
return $this;
}
public function getMediaName(): ?string
{
return $this->mediaName;
}
public function setMediaName(?string $mediaName): self
{
$this->mediaName = $mediaName;
return $this;
}
public function getMediaFile(): ?File
{
return $this->mediaFile;
}
/**
* @param File|null $image
*/
public function setMediaFile(File $mediaFile = null)
{
$this->mediaFile = $mediaFile;
// 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 ($mediaFile) {
$this->updatedAt = new \DateTime('now');
}
}
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 getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
}