src/Entity/Events.php line 22

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 App\Repository\EventsRepository;
  8. use DateTimeImmutable;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Exception;
  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=EventsRepository::class)
  17.  * @Vich\Uploadable
  18.  */
  19. class Events
  20. {
  21.     use IdTrait;
  22.     use OrdreTrait;
  23.     use DatesTrait;
  24.     use SlugTrait;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      * @Assert\NotBlank(message="Veuillez saisir le nom de l'event")
  28.      */
  29.     private $name;
  30.     /**
  31.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  32.      *
  33.      * @Vich\UploadableField(mapping="events_image", fileNameProperty="filename")
  34.      * @var File|null
  35.      * @Assert\Image(
  36.      *     mimeTypes={"image/jpeg", "image/png"},
  37.      *
  38.      *     maxHeight=1280,
  39.      *     maxWidth=1920,
  40.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  41.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  42.      * )
  43.      */
  44.     private $imageFile;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $filename;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $localisation;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true)
  55.      */
  56.     private $date;
  57.     /**
  58.      * @ORM\Column(type="text", nullable=true)
  59.      */
  60.     private $description;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity=Periodes::class, inversedBy="events")
  63.      */
  64.     private $periodes;
  65.     public function getName(): ?string
  66.     {
  67.         return $this->name;
  68.     }
  69.     public function setName(string $name): self
  70.     {
  71.         $this->name $name;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return File|null
  76.      */
  77.     public function getImageFile(): ?File
  78.     {
  79.         return $this->imageFile;
  80.     }
  81.     /**
  82.      * @param File|null $imageFile
  83.      * @return Events
  84.      * @throws Exception
  85.      */
  86.     public function setImageFile(?File $imageFile): Events
  87.     {
  88.         $this->imageFile $imageFile;
  89.         if ($this->imageFile instanceof UploadedFile) {
  90.             // It is required that at least one field changes if you are using doctrine
  91.             // otherwise the event listeners won't be called and the file is lost
  92.             $this->updatedAt = new DateTimeImmutable('now');
  93.         }
  94.         return $this;
  95.     }
  96.     public function getFilename(): ?string
  97.     {
  98.         return $this->filename;
  99.     }
  100.     public function setFilename(?string $filename): self
  101.     {
  102.         $this->filename $filename;
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return mixed
  107.      */
  108.     public function getLocalisation()
  109.     {
  110.         return $this->localisation;
  111.     }
  112.     /**
  113.      * @param mixed localisation
  114.      * @return Events
  115.      */
  116.     public function setLocalisation($localisation): Events
  117.     {
  118.         $this->localisation $localisation;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return mixed
  123.      */
  124.     public function getDate()
  125.     {
  126.         return $this->date;
  127.     }
  128.     /**
  129.      * @param mixed $date
  130.      * @return Events
  131.      */
  132.     public function setDate($date): Events
  133.     {
  134.         $this->date $date;
  135.         return $this;
  136.     }
  137.     public function getDescription(): ?string
  138.     {
  139.         return $this->description;
  140.     }
  141.     public function setDescription(?string $description): self
  142.     {
  143.         $this->description $description;
  144.         return $this;
  145.     }
  146.     public function getPeriodes(): ?Periodes
  147.     {
  148.         return $this->periodes;
  149.     }
  150.     public function setPeriodes(?Periodes $periodes): self
  151.     {
  152.         $this->periodes $periodes;
  153.         return $this;
  154.     }
  155. }