<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\File;
use App\Repository\CatalogRepository;
/**
* Catalog
*
* @ORM\Table(name="catalog")
* @ORM\Entity(repositoryClass="App\Repository\CatalogRepository")
* @Vich\Uploadable
*/
class Catalog
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Language::class)
* @ORM\JoinColumn(nullable=false)
*/
private $lang;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string|null
*/
private $url;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string|null
*/
private $thumbnail;
/**
* @Vich\UploadableField(mapping="catalog_pdf", fileNameProperty="thumbnail")
*
* @var file|null
*
* @Assert\File(
* maxSize = "2M",
* mimeTypes = {"image/jpeg", "image/png"},
* maxSizeMessage = "La taille maximale de l'image est 2MB.",
* mimeTypesMessage = "Seulement les fichiers de type png et jpg sont autorisées"
* )
*/
private $thumbnailFile;
public function getId(): ?int
{
return $this->id;
}
public function getLang(): ?Language
{
return $this->lang;
}
public function setLang(?Language $lang): self
{
$this->lang = $lang;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl($url = null): self
{
$this->url = $url;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getThumbnail()
{
return $this->thumbnail;
}
public function setThumbnail($thumbnail): self
{
$this->thumbnail = $thumbnail;
return $this;
}
/**
* Get file
*
* @return string
*/
public function getThumbnailFile()
{
return $this->thumbnailFile;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $thumbnailFile
*/
public function setThumbnailFile(File $thumbnailFile = null)
{
$this->thumbnailFile = $thumbnailFile;
if (null !== $thumbnailFile) {
// 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();
}
}
}