src/Entity/Articles/Articles.php line 26

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