src/Entity/Brochures.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Common\DatesTrait;
  4. use App\Entity\Common\IdTrait;
  5. use App\Entity\Common\OrdreTrait;
  6. use App\Entity\Common\SlugTrait;
  7. use DateTimeImmutable;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Exception;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\HttpFoundation\File\File;
  12. use Symfony\Component\HttpFoundation\File\UploadedFile;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  15. /**
  16.  * @ORM\Entity(repositoryClass="App\Repository\BrochuresRepository")
  17.  * @UniqueEntity("name")
  18.  * @Vich\Uploadable
  19.  */
  20. class Brochures
  21. {
  22.     use IdTrait;
  23.     use OrdreTrait;
  24.     use DatesTrait;
  25.     use SlugTrait;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      * @Assert\NotBlank(message="Veuillez saisir le nom du brochure")
  29.      */
  30.     private $name;
  31.     /**
  32.      * @ORM\Column(type="string", length=500, nullable=true)
  33.      */
  34.     private $extrait;
  35.     /**
  36.      * @ORM\Column(type="text", nullable=true)
  37.      */
  38.     private $content;
  39.     /**
  40.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  41.      *
  42.      * @Vich\UploadableField(mapping="brochures_image", fileNameProperty="filename")
  43.      * @var File|null
  44.      * @Assert\Image(
  45.      *     mimeTypes={"image/jpeg", "image/png"},
  46.      *
  47.      *     maxHeight=1280,
  48.      *     maxWidth=1920,
  49.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  50.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  51.      * )
  52.      */
  53.     private $imageFile;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $filename;
  58.     /**
  59.      * @ORM\Column(type="integer", nullable=true, options={"default": 0})
  60.      */
  61.     private $views;
  62.     /**
  63.      * @ORM\Column(type="boolean")
  64.      */
  65.     private $online;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="brochures")
  68.      */
  69.     private $user;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  72.      */
  73.     private $updatedBy;
  74.     /**
  75.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  76.      *
  77.      * @Vich\UploadableField(mapping="brochures_files", fileNameProperty="pdffilename")
  78.      * @var File|null
  79.      * @Assert\File(
  80.      *     mimeTypes={"application/pdf", "application/x-pdf"},
  81.      *     maxSize="30M",  maxSizeMessage = "Le fichier est trop volumineux. Sa taille ne doit pas dépasser {{size}}."
  82.      * )
  83.      */
  84.     private $documentsFile;
  85.     /**
  86.      * @ORM\Column(type="string", nullable=true, length=255)
  87.      */
  88.     private $pdffilename;
  89.     /**
  90.      * @ORM\Column(type="boolean", options={"default": 0})
  91.      */
  92.     private $featured;
  93.     public function getName(): ?string
  94.     {
  95.         return $this->name;
  96.     }
  97.     public function setName(string $name): self
  98.     {
  99.         $this->name $name;
  100.         return $this;
  101.     }
  102.     public function getExtrait(): ?string
  103.     {
  104.         return $this->extrait;
  105.     }
  106.     public function setExtrait(?string $extrait): self
  107.     {
  108.         $this->extrait $extrait;
  109.         return $this;
  110.     }
  111.     public function getContent(): ?string
  112.     {
  113.         return $this->content;
  114.     }
  115.     public function setContent(?string $content): self
  116.     {
  117.         $this->content $content;
  118.         return $this;
  119.     }
  120.     public function getViews(): ?int
  121.     {
  122.         return $this->views;
  123.     }
  124.     public function setViews(int $views): self
  125.     {
  126.         $this->views $views;
  127.         return $this;
  128.     }
  129.     public function getOnline(): ?bool
  130.     {
  131.         return $this->online;
  132.     }
  133.     public function setOnline(bool $online): self
  134.     {
  135.         $this->online $online;
  136.         return $this;
  137.     }
  138.     public function getUser(): ?User
  139.     {
  140.         return $this->user;
  141.     }
  142.     public function setUser(?User $user): self
  143.     {
  144.         $this->user $user;
  145.         return $this;
  146.     }
  147.     public function getUpdatedBy(): ?User
  148.     {
  149.         return $this->updatedBy;
  150.     }
  151.     public function setUpdatedBy(?User $updatedBy): self
  152.     {
  153.         $this->updatedBy $updatedBy;
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return File|null
  158.      */
  159.     public function getImageFile(): ?File
  160.     {
  161.         return $this->imageFile;
  162.     }
  163.     /**
  164.      * @param File|null $imageFile
  165.      * @return Brochures
  166.      * @throws Exception
  167.      */
  168.     public function setImageFile(?File $imageFile): Brochures
  169.     {
  170.         $this->imageFile $imageFile;
  171.         if ($this->imageFile instanceof UploadedFile) {
  172.             // It is required that at least one field changes if you are using doctrine
  173.             // otherwise the event listeners won't be called and the file is lost
  174.             $this->updatedAt = new DateTimeImmutable('now');
  175.         }
  176.         return $this;
  177.     }
  178.     public function getFilename(): ?string
  179.     {
  180.         return $this->filename;
  181.     }
  182.     public function setFilename(?string $filename): self
  183.     {
  184.         $this->filename $filename;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return File|null
  189.      */
  190.     public function getDocumentsFile(): ?File
  191.     {
  192.         return $this->documentsFile;
  193.     }
  194.     /**
  195.      * @param File|null $documentsFile
  196.      * @return Brochures
  197.      * @throws Exception
  198.      */
  199.     public function setDocumentsFile(?File $documentsFile): Brochures
  200.     {
  201.         $this->documentsFile $documentsFile;
  202.         if ($this->documentsFile instanceof UploadedFile) {
  203.             // It is required that at least one field changes if you are using doctrine
  204.             // otherwise the event listeners won't be called and the file is lost
  205.             $this->updatedAt = new \DateTime('now');
  206.         }
  207.         return $this;
  208.     }
  209.     public function getPdffilename(): ?string
  210.     {
  211.         return $this->pdffilename;
  212.     }
  213.     public function setPdffilename(string $pdffilename): self
  214.     {
  215.         $this->pdffilename $pdffilename;
  216.         return $this;
  217.     }
  218.     public function getFeatured(): ?bool
  219.     {
  220.         return $this->featured;
  221.     }
  222.     public function setFeatured(bool $featured): self
  223.     {
  224.         $this->featured $featured;
  225.         return $this;
  226.     }
  227. }