src/Entity/Symboles/Symbolesetats.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Symboles;
  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\Symboles\SymbolesetatsRepository;
  8. use DateTime;
  9. use DateTimeImmutable;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Exception;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Symfony\Component\HttpFoundation\File\File;
  16. use Symfony\Component\HttpFoundation\File\UploadedFile;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  19. /**
  20.  * @ORM\Entity(repositoryClass=SymbolesetatsRepository::class)
  21.  * @UniqueEntity("name")
  22.  * @Vich\Uploadable
  23.  */
  24. class Symbolesetats
  25. {
  26.     use IdTrait;
  27.     use OrdreTrait;
  28.     use DatesTrait;
  29.     use SlugTrait;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      * @Assert\NotBlank(message="Veuillez saisir un titre")
  33.      */
  34.     private $name;
  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="symboles_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="boolean")
  60.      */
  61.     private $online;
  62.     /**
  63.      * @ORM\OneToMany(targetEntity=Mediassymboles::class, mappedBy="symbolesetats")
  64.      */
  65.     private $mediassymboles;
  66.     public function __construct()
  67.     {
  68.         $this->mediassymboles = new ArrayCollection();
  69.     }
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function setName(string $name): self
  75.     {
  76.         $this->name $name;
  77.         return $this;
  78.     }
  79.     public function getContent(): ?string
  80.     {
  81.         return $this->content;
  82.     }
  83.     public function setContent(?string $content): self
  84.     {
  85.         $this->content $content;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @return File|null
  90.      */
  91.     public function getImageFile(): ?File
  92.     {
  93.         return $this->imageFile;
  94.     }
  95.     /**
  96.      * @param File|null $imageFile
  97.      * @return Symbolesetats
  98.      * @throws Exception
  99.      */
  100.     public function setImageFile(?File $imageFile): Symbolesetats
  101.     {
  102.         $this->imageFile $imageFile;
  103.         if ($this->imageFile instanceof UploadedFile) {
  104.             // It is required that at least one field changes if you are using doctrine
  105.             // otherwise the event listeners won't be called and the file is lost
  106.             $this->updatedAt = new DateTimeImmutable('now');
  107.         }
  108.         return $this;
  109.     }
  110.     public function getFilename(): ?string
  111.     {
  112.         return $this->filename;
  113.     }
  114.     public function setFilename(?string $filename): self
  115.     {
  116.         $this->filename $filename;
  117.         return $this;
  118.     }
  119.     public function getOnline(): ?bool
  120.     {
  121.         return $this->online;
  122.     }
  123.     public function setOnline(bool $online): self
  124.     {
  125.         $this->online $online;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection|Mediassymboles[]
  130.      */
  131.     public function getMediassymboles(): Collection
  132.     {
  133.         return $this->mediassymboles;
  134.     }
  135.     public function addMediassymbole(Mediassymboles $mediassymbole): self
  136.     {
  137.         if (!$this->mediassymboles->contains($mediassymbole)) {
  138.             $this->mediassymboles[] = $mediassymbole;
  139.             $mediassymbole->setSymbolesetats($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeMediassymbole(Mediassymboles $mediassymbole): self
  144.     {
  145.         if ($this->mediassymboles->contains($mediassymbole)) {
  146.             $this->mediassymboles->removeElement($mediassymbole);
  147.             // set the owning side to null (unless already changed)
  148.             if ($mediassymbole->getSymbolesetats() === $this) {
  149.                 $mediassymbole->setSymbolesetats(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154. }