src/Entity/Actualites/Actualites.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Actualites;
  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\Entity\User;
  8. use DateTimeImmutable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use Symfony\Component\HttpFoundation\File\File;
  14. use Symfony\Component\HttpFoundation\File\UploadedFile;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  17. /**
  18.  * @ORM\Entity(repositoryClass="App\Repository\Actualites\ActualitesRepository")
  19.  * @UniqueEntity("name")
  20.  * @Vich\Uploadable
  21.  */
  22. class Actualites
  23. {
  24.     use IdTrait;
  25.     use OrdreTrait;
  26.     use DatesTrait;
  27.     use SlugTrait;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      * @Assert\NotBlank(message="Veuillez saisir le nom pour l'actualité")
  31.      */
  32.     private $name;
  33.     /**
  34.      * @ORM\Column(type="string", length=500, nullable=true)
  35.      */
  36.     private $description;
  37.     /**
  38.      * @ORM\Column(type="text")
  39.      * @Assert\NotBlank(message="Veuillez saisir le contenu pour l'actualité")
  40.      */
  41.     private $content;
  42.     /**
  43.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  44.      *
  45.      * @Vich\UploadableField(mapping="actualites_image", fileNameProperty="filename")
  46.      * @var File|null
  47.      * @Assert\Image(
  48.      *     mimeTypes={"image/jpeg", "image/png"},
  49.      *
  50.      *     maxHeight=1280,
  51.      *     maxWidth=1920,
  52.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  53.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  54.      * )
  55.      */
  56.     private $imageFile;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private $filename;
  61.     /**
  62.      * @ORM\Column(type="boolean", nullable=true)
  63.      */
  64.     private $online;
  65.     /**
  66.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="actualites")
  67.      */
  68.     private $user;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity="App\Entity\Actualites\Categories", inversedBy="actualites")
  71.      */
  72.     private $categories;
  73.     /**
  74.      * @ORM\Column(type="boolean", nullable=true, options={"default": 0})
  75.      */
  76.     private $featured;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity="App\Entity\Actualites\Mediasactualites", mappedBy="actualites")
  79.      */
  80.     private $mediasactualites;
  81.     /**
  82.      * @ORM\Column(type="integer", nullable=true, options={"default": 0})
  83.      */
  84.     private $views;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="actualitesUpatedBy")
  87.      */
  88.     private $updatedBy;
  89.     /**
  90.      * @ORM\Column(type="string", length=255)
  91.      */
  92.     private $published;
  93.     /**
  94.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  95.      *
  96.      * @Vich\UploadableField(mapping="bandeau_actualite", fileNameProperty="bandeaufile")
  97.      * @var File|null
  98.      * @Assert\Image(
  99.      *     mimeTypes={"image/jpeg", "image/png"},
  100.      *
  101.      *     maxHeight=230,
  102.      *     maxWidth=1920,
  103.      *     maxHeightMessage="Votre image doit faire 230 d'hauteur",
  104.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  105.      * )
  106.      */
  107.     private $imageBandeauFile;
  108.     /**
  109.      * @ORM\Column(type="string", length=255, nullable=true)
  110.      */
  111.     private $bandeaufile;
  112.     public function __construct()
  113.     {
  114.         $this->mediasactualites = new ArrayCollection();
  115.     }
  116.     public function getName(): ?string
  117.     {
  118.         return $this->name;
  119.     }
  120.     public function setName(string $name): self
  121.     {
  122.         $this->name $name;
  123.         return $this;
  124.     }
  125.     public function getDescription(): ?string
  126.     {
  127.         return $this->description;
  128.     }
  129.     public function setDescription(?string $description): self
  130.     {
  131.         $this->description $description;
  132.         return $this;
  133.     }
  134.     public function getContent(): ?string
  135.     {
  136.         return $this->content;
  137.     }
  138.     public function setContent(string $content): self
  139.     {
  140.         $this->content $content;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return File|null
  145.      */
  146.     public function getImageFile(): ?File
  147.     {
  148.         return $this->imageFile;
  149.     }
  150.     /**
  151.      * @param File|null $imageFile
  152.      * @return Actualites
  153.      * @throws \Exception
  154.      */
  155.     public function setImageFile(?File $imageFile): Actualites
  156.     {
  157.         $this->imageFile $imageFile;
  158.         if ($this->imageFile instanceof UploadedFile) {
  159.             // It is required that at least one field changes if you are using doctrine
  160.             // otherwise the event listeners won't be called and the file is lost
  161.             $this->updatedAt = new DateTimeImmutable('now');
  162.         }
  163.         return $this;
  164.     }
  165.     public function getFilename(): ?string
  166.     {
  167.         return $this->filename;
  168.     }
  169.     public function setFilename(?string $filename): self
  170.     {
  171.         $this->filename $filename;
  172.         return $this;
  173.     }
  174.     public function getOnline(): ?bool
  175.     {
  176.         return $this->online;
  177.     }
  178.     public function setOnline(?bool $online): self
  179.     {
  180.         $this->online $online;
  181.         return $this;
  182.     }
  183.     public function getUser(): ?User
  184.     {
  185.         return $this->user;
  186.     }
  187.     public function setUser(?User $user): self
  188.     {
  189.         $this->user $user;
  190.         return $this;
  191.     }
  192.     public function getCategories(): ?Categories
  193.     {
  194.         return $this->categories;
  195.     }
  196.     public function setCategories(?Categories $categories): self
  197.     {
  198.         $this->categories $categories;
  199.         return $this;
  200.     }
  201.     public function __toString()
  202.     {
  203.         return $this->name;
  204.     }
  205.     public function getFeatured(): ?bool
  206.     {
  207.         return $this->featured;
  208.     }
  209.     public function setFeatured(?bool $featured): self
  210.     {
  211.         $this->featured $featured;
  212.         return $this;
  213.     }
  214.     /**
  215.      * @return Collection|Mediasactualites[]
  216.      */
  217.     public function getMediasactualites(): Collection
  218.     {
  219.         return $this->mediasactualites;
  220.     }
  221.     public function addMediasactuality(Mediasactualites $mediasactuality): self
  222.     {
  223.         if (!$this->mediasactualites->contains($mediasactuality)) {
  224.             $this->mediasactualites[] = $mediasactuality;
  225.             $mediasactuality->setActualites($this);
  226.         }
  227.         return $this;
  228.     }
  229.     public function removeMediasactuality(Mediasactualites $mediasactuality): self
  230.     {
  231.         if ($this->mediasactualites->contains($mediasactuality)) {
  232.             $this->mediasactualites->removeElement($mediasactuality);
  233.             // set the owning side to null (unless already changed)
  234.             if ($mediasactuality->getActualites() === $this) {
  235.                 $mediasactuality->setActualites(null);
  236.             }
  237.         }
  238.         return $this;
  239.     }
  240.     public function getViews(): ?int
  241.     {
  242.         return $this->views;
  243.     }
  244.     public function setViews(int $views): self
  245.     {
  246.         $this->views $views;
  247.         return $this;
  248.     }
  249.     public function getUpdatedBy(): ?User
  250.     {
  251.         return $this->updatedBy;
  252.     }
  253.     public function setUpdatedBy(?User $updatedBy): self
  254.     {
  255.         $this->updatedBy $updatedBy;
  256.         return $this;
  257.     }
  258.     public function getPublished(): ?string
  259.     {
  260.         return $this->published;
  261.     }
  262.     public function setPublished(string $published): self
  263.     {
  264.         $this->published $published;
  265.         return $this;
  266.     }
  267.     /**
  268.      * @return File|null
  269.      */
  270.     public function getImageBandeauFile(): ?File
  271.     {
  272.         return $this->imageBandeauFile;
  273.     }
  274.     /**
  275.      * @param File|null $imageBandeauFile
  276.      * @return Actualites
  277.      */
  278.     public function setImageBandeauFile(?File $imageBandeauFile): Actualites
  279.     {
  280.         $this->imageBandeauFile $imageBandeauFile;
  281.         if ($this->imageBandeauFile instanceof UploadedFile) {
  282.             // It is required that at least one field changes if you are using doctrine
  283.             // otherwise the event listeners won't be called and the file is lost
  284.             $this->updatedAt = new \DateTime('now');
  285.         }
  286.         return $this;
  287.     }
  288.     public function getBandeaufile(): ?string
  289.     {
  290.         return $this->bandeaufile;
  291.     }
  292.     public function setBandeaufile(?string $bandeaufile): self
  293.     {
  294.         $this->bandeaufile $bandeaufile;
  295.         return $this;
  296.     }
  297. }