src/Entity/Institutions.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\InstitutionsRepository")
  17.  * @UniqueEntity("name")
  18.  * @Vich\Uploadable
  19.  */
  20. class Institutions
  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 titre")
  29.      */
  30.     private $name;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $link;
  35.     /**
  36.      * @ORM\Column(type="string", length=500, nullable=true)
  37.      */
  38.     private $extrait;
  39.     /**
  40.      * @ORM\Column(type="text", nullable=true)
  41.      */
  42.     private $content;
  43.     /**
  44.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  45.      *
  46.      * @Vich\UploadableField(mapping="institutions_image", fileNameProperty="filename")
  47.      * @var File|null
  48.      * @Assert\Image(
  49.      *     mimeTypes={"image/jpeg", "image/png"},
  50.      *
  51.      *     maxHeight=1280,
  52.      *     maxWidth=1920,
  53.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  54.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  55.      * )
  56.      */
  57.     private $imageFile;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $filename;
  62.     /**
  63.      * @ORM\Column(type="boolean")
  64.      */
  65.     private $online;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="institutions")
  68.      */
  69.     private $user;
  70.     /**
  71.      * @ORM\Column(type="integer", nullable=true, options={"default": 0})
  72.      */
  73.     private $views;
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  76.      */
  77.     private $updatedBy;
  78.     public function getName(): ?string
  79.     {
  80.         return $this->name;
  81.     }
  82.     public function setName(string $name): self
  83.     {
  84.         $this->name $name;
  85.         return $this;
  86.     }
  87.     public function getLink(): ?string
  88.     {
  89.         return $this->link;
  90.     }
  91.     public function setLink(?string $link): self
  92.     {
  93.         $this->link $link;
  94.         return $this;
  95.     }
  96.     public function getExtrait(): ?string
  97.     {
  98.         return $this->extrait;
  99.     }
  100.     public function setExtrait(?string $extrait): self
  101.     {
  102.         $this->extrait $extrait;
  103.         return $this;
  104.     }
  105.     public function getContent(): ?string
  106.     {
  107.         return $this->content;
  108.     }
  109.     public function setContent(?string $content): self
  110.     {
  111.         $this->content $content;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return File|null
  116.      */
  117.     public function getImageFile(): ?File
  118.     {
  119.         return $this->imageFile;
  120.     }
  121.     /**
  122.      * @param File|null $imageFile
  123.      * @return Institutions
  124.      * @throws Exception
  125.      */
  126.     public function setImageFile(?File $imageFile): Institutions
  127.     {
  128.         $this->imageFile $imageFile;
  129.         if ($this->imageFile instanceof UploadedFile) {
  130.             // It is required that at least one field changes if you are using doctrine
  131.             // otherwise the event listeners won't be called and the file is lost
  132.             $this->updatedAt = new DateTimeImmutable('now');
  133.         }
  134.         return $this;
  135.     }
  136.     public function getFilename(): ?string
  137.     {
  138.         return $this->filename;
  139.     }
  140.     public function setFilename(?string $filename): self
  141.     {
  142.         $this->filename $filename;
  143.         return $this;
  144.     }
  145.     public function getOnline(): ?bool
  146.     {
  147.         return $this->online;
  148.     }
  149.     public function setOnline(bool $online): self
  150.     {
  151.         $this->online $online;
  152.         return $this;
  153.     }
  154.     public function getUser(): ?User
  155.     {
  156.         return $this->user;
  157.     }
  158.     public function setUser(?User $user): self
  159.     {
  160.         $this->user $user;
  161.         return $this;
  162.     }
  163.     public function getViews(): ?int
  164.     {
  165.         return $this->views;
  166.     }
  167.     public function setViews(int $views): self
  168.     {
  169.         $this->views $views;
  170.         return $this;
  171.     }
  172.     public function getUpdatedBy(): ?User
  173.     {
  174.         return $this->updatedBy;
  175.     }
  176.     public function setUpdatedBy(?User $updatedBy): self
  177.     {
  178.         $this->updatedBy $updatedBy;
  179.         return $this;
  180.     }
  181. }