<?php
namespace App\Entity;
use App\Repository\CategoriProductRepository;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=CategoriProductRepository::class)
* @Vich\Uploadable
*/
class CategoriProduct
{
public const MAX_IMAGE_FILESIZE = 2097152; // 2MB
public const MESSAGE_IMAGE_FILESIZE = "La taille maximale d'image autorisée est de 2MB.";
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imageName;
/**
* @Vich\UploadableField(mapping="categorie_image", fileNameProperty="imageName")
* @var File|null
*/
private $imageFile;
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;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageName(string $imageName): self
{
$this->imageName = $imageName;
return $this;
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function setImageFile(?File $imageFile): self
{
$this->imageFile = $imageFile;
if ($imageFile) {
// 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();
}
return $this;
}
}