src/Entity/Catalog.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use Symfony\Component\HttpFoundation\File\UploadedFile;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use App\Repository\CatalogRepository;
  9.  /**
  10.  * Catalog
  11.  *
  12.  * @ORM\Table(name="catalog")
  13.  * @ORM\Entity(repositoryClass="App\Repository\CatalogRepository")
  14.  * @Vich\Uploadable
  15.  */
  16. class Catalog
  17. {
  18.     /**
  19.      * @ORM\Id()
  20.      * @ORM\GeneratedValue()
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=Language::class)
  26.      * @ORM\JoinColumn(nullable=false)
  27.      */
  28.     private $lang;
  29.     /**
  30.      * @ORM\Column(type="string", length=255, nullable=true)
  31.      */
  32.     private $title;
  33.     
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      * @var string|null
  37.      */
  38.     private $url;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      * @var string|null
  42.      */
  43.     private $thumbnail;
  44.     /**
  45.      * @Vich\UploadableField(mapping="catalog_pdf", fileNameProperty="thumbnail")
  46.      *
  47.      * @var file|null
  48.      *
  49.      * @Assert\File(
  50.      *     maxSize = "2M",
  51.      *     mimeTypes = {"image/jpeg", "image/png"},
  52.      *     maxSizeMessage = "La taille maximale de l'image est 2MB.",
  53.      *     mimeTypesMessage = "Seulement les fichiers de type png et jpg sont autorisées"
  54.      * )
  55.      */
  56.     private $thumbnailFile;
  57.     
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getLang(): ?Language
  63.     {
  64.         return $this->lang;
  65.     }
  66.     public function setLang(?Language $lang): self
  67.     {
  68.         $this->lang $lang;
  69.         return $this;
  70.     }
  71.     public function getUrl(): ?string
  72.     {
  73.         return $this->url;
  74.     }
  75.    
  76.     public function setUrl($url null): self
  77.     {
  78.         $this->url $url;
  79.         return $this;
  80.     }
  81.     public function getTitle(): ?string
  82.     {
  83.         return $this->title;
  84.     }
  85.     public function setTitle(string $title): self
  86.     {
  87.         $this->title $title;
  88.         return $this;
  89.     }
  90.     public function getThumbnail()
  91.     {
  92.         return $this->thumbnail;
  93.     }
  94.     public function setThumbnail($thumbnail): self
  95.     {
  96.         $this->thumbnail $thumbnail;
  97.         return $this;
  98.     }
  99.     /**
  100.      * Get file
  101.      *
  102.      * @return string
  103.      */
  104.     public function getThumbnailFile()
  105.     {
  106.         return $this->thumbnailFile;
  107.     }
  108.     /**
  109.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  110.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  111.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  112.      * must be able to accept an instance of 'File' as the bundle will inject one here
  113.      * during Doctrine hydration.
  114.      *
  115.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null  $thumbnailFile
  116.      */
  117.     public function setThumbnailFile(File  $thumbnailFile null)
  118.     {
  119.         $this->thumbnailFile $thumbnailFile;
  120.         if (null !== $thumbnailFile) {
  121.             // It is required that at least one field changes if you are using doctrine
  122.             // otherwise the event listeners won't be called and the file is lost
  123.             $this->updatedAt = new \DateTimeImmutable();
  124.         }
  125.     }
  126. }