src/Entity/Pages/Pages.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Pages;
  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\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Exception;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Symfony\Component\HttpFoundation\File\File;
  13. use Symfony\Component\HttpFoundation\File\UploadedFile;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  16. /**
  17.  * @ORM\Entity(repositoryClass="App\Repository\Pages\PagesRepository")
  18.  * @UniqueEntity("name")
  19.  * @Vich\Uploadable
  20.  */
  21. class Pages
  22. {
  23.     const MENU = [
  24.         => "Côte d'Ivoire",
  25.         => "Côte d'Ivoire tourisme",
  26.         => "Infos pratiques",
  27.         => "Nos contacts",
  28.     ];
  29.     use IdTrait;
  30.     use OrdreTrait;
  31.     use DatesTrait;
  32.     use SlugTrait;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      * @Assert\NotBlank(message="Veuillez saisir le nom de la page")
  36.      */
  37.     private $name;
  38.     /**
  39.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  40.      *
  41.      * @Vich\UploadableField(mapping="pages_cover", fileNameProperty="filename")
  42.      * @var File|null
  43.      * @Assert\Image(
  44.      *     mimeTypes={"image/jpeg", "image/png"},
  45.      *
  46.      *     maxHeight=1280,
  47.      *     maxWidth=1920,
  48.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  49.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  50.      * )
  51.      */
  52.     private $imageFile;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true)
  55.      */
  56.     private $filename;
  57.     /**
  58.      * @ORM\Column(type="boolean")
  59.      */
  60.     private $online;
  61.     /**
  62.      * @ORM\Column(type="integer")
  63.      */
  64.     private $menuId;
  65.     /**
  66.      * @ORM\Column(type="string", length=255)
  67.      * @Assert\NotBlank(message="Veuillez saisir le nom du menu")
  68.      */
  69.     private $menuName;
  70.     /**
  71.      * @ORM\Column(type="text", nullable=true)
  72.      */
  73.     private $content;
  74.     /**
  75.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  76.      *
  77.      * @Vich\UploadableField(mapping="bandeau_cover", fileNameProperty="bandeaufile")
  78.      * @var File|null
  79.      * @Assert\Image(
  80.      *     mimeTypes={"image/jpeg", "image/png"},
  81.      *
  82.      *     maxHeight=230,
  83.      *     maxWidth=1920,
  84.      *     maxHeightMessage="Votre image doit faire 230 d'hauteur",
  85.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  86.      * )
  87.      */
  88.     private $imageBandeauFile;
  89.     /**
  90.      * @ORM\Column(type="string", length=255, nullable=true)
  91.      */
  92.     private $bandeaufile;
  93.     /**
  94.      * @ORM\OneToMany(targetEntity="App\Entity\Pages\Mediapages", mappedBy="pages")
  95.      */
  96.     private $mediapages;
  97.     /**
  98.      * @ORM\Column(type="string", length=1000, nullable=true)
  99.      */
  100.     private $extrait;
  101.     public function getName(): ?string
  102.     {
  103.         return $this->name;
  104.     }
  105.     public function setName(string $name): self
  106.     {
  107.         $this->name $name;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return File|null
  112.      */
  113.     public function getImageFile(): ?File
  114.     {
  115.         return $this->imageFile;
  116.     }
  117.     /**
  118.      * @param File|null $imageFile
  119.      * @return Pages
  120.      * @throws Exception
  121.      */
  122.     public function setImageFile(?File $imageFile): Pages
  123.     {
  124.         $this->imageFile $imageFile;
  125.         if ($this->imageFile instanceof UploadedFile) {
  126.             // It is required that at least one field changes if you are using doctrine
  127.             // otherwise the event listeners won't be called and the file is lost
  128.             $this->updatedAt = new DateTimeImmutable('now');
  129.         }
  130.         return $this;
  131.     }
  132.     public function getFilename(): ?string
  133.     {
  134.         return $this->filename;
  135.     }
  136.     public function setFilename(?string $filename): self
  137.     {
  138.         $this->filename $filename;
  139.         return $this;
  140.     }
  141.     public function getOnline(): ?bool
  142.     {
  143.         return $this->online;
  144.     }
  145.     public function setOnline(bool $online): self
  146.     {
  147.         $this->online $online;
  148.         return $this;
  149.     }
  150.     public function getMenuId(): ?int
  151.     {
  152.         return $this->menuId;
  153.     }
  154.     public function setMenuId(int $menuId): self
  155.     {
  156.         $this->menuId $menuId;
  157.         return $this;
  158.     }
  159.     public function getMenuType(): string {
  160.         return self::MENU[$this->menuId];
  161.     }
  162.     public function getContent(): ?string
  163.     {
  164.         return $this->content;
  165.     }
  166.     public function setContent(?string $content): self
  167.     {
  168.         $this->content $content;
  169.         return $this;
  170.     }
  171.     public function getMenuName(): ?string
  172.     {
  173.         return $this->menuName;
  174.     }
  175.     public function setMenuName(string $menuName): self
  176.     {
  177.         $this->menuName $menuName;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return File|null
  182.      */
  183.     public function getImageBandeauFile(): ?File
  184.     {
  185.         return $this->imageBandeauFile;
  186.     }
  187.     /**
  188.      * @param File|null $imageBandeauFile
  189.      * @return Pages
  190.      */
  191.     public function setImageBandeauFile(?File $imageBandeauFile): Pages
  192.     {
  193.         $this->imageBandeauFile $imageBandeauFile;
  194.         if ($this->imageBandeauFile instanceof UploadedFile) {
  195.             // It is required that at least one field changes if you are using doctrine
  196.             // otherwise the event listeners won't be called and the file is lost
  197.             $this->updatedAt = new \DateTime('now');
  198.         }
  199.         return $this;
  200.     }
  201.     public function getBandeaufile(): ?string
  202.     {
  203.         return $this->bandeaufile;
  204.     }
  205.     public function setBandeaufile(?string $bandeaufile): self
  206.     {
  207.         $this->bandeaufile $bandeaufile;
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return Collection|Mediapages[]
  212.      */
  213.     public function getMediapages(): Collection
  214.     {
  215.         return $this->mediapages;
  216.     }
  217.     public function addMediapage(Mediapages $mediapages): self
  218.     {
  219.         if (!$this->mediapages->contains($mediapages)) {
  220.             $this->mediapages[] = $mediapages;
  221.             $mediapages->setPages($this);
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeMediapage(Mediapages $mediapages): self
  226.     {
  227.         if ($this->mediapages->contains($mediapages)) {
  228.             $this->mediapages->removeElement($mediapages);
  229.             // set the owning side to null (unless already changed)
  230.             if ($mediapages->getPages() === $this) {
  231.                 $mediapages->setPages(null);
  232.             }
  233.         }
  234.         return $this;
  235.     }
  236.     public function getExtrait(): ?string
  237.     {
  238.         return $this->extrait;
  239.     }
  240.     public function setExtrait(?string $extrait): self
  241.     {
  242.         $this->extrait $extrait;
  243.         return $this;
  244.     }
  245. }