src/Entity/Site/Article.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Site;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Entity\Template\Row;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\Site\ArticleRepository")
  13.  * @UniqueEntity("seoUrl")
  14.  * @Vich\Uploadable
  15.  */
  16. class Article
  17. {
  18.     /**
  19.      * @ORM\Id()
  20.      * @ORM\GeneratedValue()
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="integer", nullable=true)
  26.      */
  27.     private $placement;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $titre;
  32.     /**
  33.      * @ORM\Column(type="text")
  34.      */
  35.     private $resume;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity="App\Entity\Template\Row", mappedBy="article", orphanRemoval=true, cascade={"persist"})
  38.      * @ORM\OrderBy({"placement" = "ASC"})
  39.      */
  40.     private $rows;
  41.     
  42.     /**
  43.      * @ORM\Column(type="date")
  44.      */
  45.     private $date;
  46.     /**
  47.      * @ORM\Column(type="text", nullable=true)
  48.      */
  49.     private $pdf;
  50.     //--------------------------------------------------------- 
  51.     //                  VICHUPLOADER propriété START
  52.     //--------------------------------------------------------- 
  53.     /**
  54.      * @ORM\Column(type="text")
  55.      */
  56.     private $imageUrl;
  57.     /**
  58.      * @ORM\Column(type="text")
  59.      */
  60.     private $imageBisUrl;
  61.     /**
  62.      * @ORM\Column(type="text")
  63.      */
  64.     private $imageTerUrl;
  65.     /**
  66.      * @Vich\UploadableField(mapping="article_images", fileNameProperty="imageUrl")
  67.      * @Assert\File(
  68.      *     maxSize = "350k",
  69.      *     maxSizeMessage = "La taille maximale autorisée et de {{ limit }} {{ suffix }}, {{ name }} fait {{ size }} {{ suffix }}.",
  70.      *     mimeTypes = {"image/jpg", "image/jpeg", "image/png", "image/svg", "image/webp"},
  71.      *     mimeTypesMessage = "{{ name }} possède un format non pris en charge ({{ type }}), les formats autorisés sont : {{ types }}."
  72.      * )
  73.      * @var File
  74.      */
  75.     private $imageFile;
  76.     /**
  77.      * @Vich\UploadableField(mapping="article_images", fileNameProperty="imageBisUrl")
  78.      * @Assert\File(
  79.      *     maxSize = "350k",
  80.      *     maxSizeMessage = "La taille maximale autorisée et de {{ limit }} {{ suffix }}, {{ name }} fait {{ size }} {{ suffix }}.",
  81.      *     mimeTypes = {"image/jpg", "image/jpeg", "image/png", "image/svg", "image/webp"},
  82.      *     mimeTypesMessage = "{{ name }} possède un format non pris en charge ({{ type }}), les formats autorisés sont : {{ types }}."
  83.      * )
  84.      * @var File
  85.      */
  86.     private $imageBisFile;
  87.     /**
  88.      * @Vich\UploadableField(mapping="article_images", fileNameProperty="imageTerUrl")
  89.      * @Assert\File(
  90.      *     maxSize = "350k",
  91.      *     maxSizeMessage = "La taille maximale autorisée et de {{ limit }} {{ suffix }}, {{ name }} fait {{ size }} {{ suffix }}.",
  92.      *     mimeTypes = {"image/jpg", "image/jpeg", "image/png", "image/svg", "image/webp"},
  93.      *     mimeTypesMessage = "{{ name }} possède un format non pris en charge ({{ type }}), les formats autorisés sont : {{ types }}."
  94.      * )
  95.      * @var File
  96.      */
  97.     private $imageTerFile;
  98.     /**
  99.      * @ORM\Column(type="date")
  100.      */
  101.     private $updatedAt;
  102.     
  103.     //--------------------------------------------------------- 
  104.     //                  VICHUPLOADER propriété END
  105.     //--------------------------------------------------------- 
  106.     /**
  107.      * @ORM\Column(type="string", length=255)
  108.      */
  109.     private $seoUrl;
  110.     /**
  111.      * @ORM\Column(type="string", length=255, nullable=true)
  112.      */
  113.     private $metaTitle;
  114.     /**
  115.      * @ORM\Column(type="text", nullable=true)
  116.      */
  117.     private $metaDescription;
  118.     /**
  119.      * @ORM\ManyToOne(targetEntity="App\Entity\Site\ArticleTag", inversedBy="articles")
  120.      * @ORM\JoinColumn(nullable=false)
  121.      */
  122.     private $tag;
  123.     /**
  124.      * @ORM\Column(type="date", nullable=true)
  125.      */
  126.     private $dateFin;
  127.     /**
  128.      * @ORM\Column(type="string", length=255)
  129.      */
  130.     private $imageAlt;
  131.     /**
  132.      * @ORM\ManyToMany(targetEntity=ArticleTagProduit::class, inversedBy="articles")
  133.      */
  134.     private $tagProduits;
  135.     public function __construct()
  136.     {
  137.         $this->rows = new ArrayCollection();
  138.         $this->date = new \DateTime('now');
  139.         $this->updatedAt = new \DateTime('now');
  140.         $this->tagProduits = new ArrayCollection();
  141.     }
  142.     public function __toString()
  143.     {
  144.         return $this->getTitre();
  145.     }
  146.     //--------------------------------------------------------- 
  147.     //                  VICHUPLOADER méthode START
  148.     //--------------------------------------------------------- 
  149.     public function setImageFile(File $url null)
  150.     {
  151.         $this->imageFile $url;
  152.         // VERY IMPORTANT:
  153.         // It is required that at least one field changes if you are using Doctrine,
  154.         // otherwise the event listeners won't be called and the file is lost
  155.         if ($url) {
  156.             // if 'updatedAt' is not defined in your entity, use another property
  157.             $this->updatedAt = new \DateTime('now');
  158.         }
  159.     }
  160.     public function getImageFile()
  161.     {
  162.         return $this->imageFile;
  163.     }
  164.     public function setImageBisFile(File $url null)
  165.     {
  166.         $this->imageBisFile $url;
  167.         // VERY IMPORTANT:
  168.         // It is required that at least one field changes if you are using Doctrine,
  169.         // otherwise the event listeners won't be called and the file is lost
  170.         if ($url) {
  171.             // if 'updatedAt' is not defined in your entity, use another property
  172.             $this->updatedAt = new \DateTime('now');
  173.         }
  174.     }
  175.     public function getImageBisFile()
  176.     {
  177.         return $this->imageBisFile;
  178.     }
  179.     public function setImageTerFile(File $url null)
  180.     {
  181.         $this->imageTerFile $url;
  182.         // VERY IMPORTANT:
  183.         // It is required that at least one field changes if you are using Doctrine,
  184.         // otherwise the event listeners won't be called and the file is lost
  185.         if ($url) {
  186.             // if 'updatedAt' is not defined in your entity, use another property
  187.             $this->updatedAt = new \DateTime('now');
  188.         }
  189.     }
  190.     public function getImageTerFile()
  191.     {
  192.         return $this->imageTerFile;
  193.     }
  194.     //--------------------------------------------------------- 
  195.     //                  VICHUPLOADER méthode END
  196.     //--------------------------------------------------------- 
  197.     public function getId(): ?int
  198.     {
  199.         return $this->id;
  200.     }
  201.     public function getPlacement(): ?int
  202.     {
  203.         return $this->placement;
  204.     }
  205.     public function setPlacement(?int $placement): self
  206.     {
  207.         $this->placement $placement;
  208.         return $this;
  209.     }
  210.     public function getTitre(): ?string
  211.     {
  212.         return $this->titre;
  213.     }
  214.     public function setTitre(string $titre): self
  215.     {
  216.         $this->titre $titre;
  217.         return $this;
  218.     }
  219.     public function getSousTitre(): ?string
  220.     {
  221.         return $this->sousTitre;
  222.     }
  223.     public function setSousTitre(?string $sousTitre): self
  224.     {
  225.         $this->sousTitre $sousTitre;
  226.         return $this;
  227.     }
  228.     public function getResume(): ?string
  229.     {
  230.         return $this->resume;
  231.     }
  232.     public function setResume(string $resume): self
  233.     {
  234.         $this->resume $resume;
  235.         return $this;
  236.     }
  237.     public function getPdf(): ?string
  238.     {
  239.         return $this->pdf;
  240.     }
  241.     public function setPdf(?string $pdf): self
  242.     {
  243.         $this->pdf $pdf;
  244.         return $this;
  245.     }
  246.     public function getDate(): ?\DateTimeInterface
  247.     {
  248.         return $this->date;
  249.     }
  250.     public function setDate(?\DateTimeInterface $date): self
  251.     {
  252.         $this->date $date;
  253.         return $this;
  254.     }
  255.     public function getUpdatedAt(): ?\DateTimeInterface
  256.     {
  257.         return $this->updatedAt;
  258.     }
  259.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  260.     {
  261.         $this->updatedAt $updatedAt;
  262.         return $this;
  263.     }
  264.     public function getSeoUrl(): ?string
  265.     {
  266.         return $this->seoUrl;
  267.     }
  268.     public function setSeoUrl(string $seoUrl): self
  269.     {
  270.         $this->seoUrl $seoUrl;
  271.         return $this;
  272.     }
  273.     
  274.     public function getImageUrl(): ?string
  275.     {
  276.         return $this->imageUrl;
  277.     }
  278.     public function setImageUrl(?string $imageUrl): self
  279.     {
  280.         $this->imageUrl $imageUrl;
  281.         return $this;
  282.     }
  283.     public function getImageBisUrl(): ?string
  284.     {
  285.         return $this->imageBisUrl;
  286.     }
  287.     public function setImageBisUrl(?string $imageBisUrl): self
  288.     {
  289.         $this->imageBisUrl $imageBisUrl;
  290.         return $this;
  291.     }
  292.     public function getImageTerUrl(): ?string
  293.     {
  294.         return $this->imageTerUrl;
  295.     }
  296.     public function setImageTerUrl(?string $imageTerUrl): self
  297.     {
  298.         $this->imageTerUrl $imageTerUrl;
  299.         return $this;
  300.     }
  301.     /**
  302.      * @return Collection|Row[]
  303.      */
  304.     public function getRows(): Collection
  305.     {
  306.         return $this->rows;
  307.     }
  308.     public function addRow(Row $row): self
  309.     {
  310.         if (!$this->rows->contains($row)) {
  311.             $this->rows[] = $row;
  312.             $row->setArticle($this);
  313.         }
  314.         return $this;
  315.     }
  316.     public function removeRow(Row $row): self
  317.     {
  318.         if ($this->rows->contains($row)) {
  319.             $this->rows->removeElement($row);
  320.             // set the owning side to null (unless already changed)
  321.             if ($row->getArticle() === $this) {
  322.                 $row->setArticle(null);
  323.             }
  324.         }
  325.         return $this;
  326.     }
  327.     public function getMetaTitle(): ?string
  328.     {
  329.         return $this->metaTitle;
  330.     }
  331.     public function setMetaTitle(?string $metaTitle): self
  332.     {
  333.         $this->metaTitle $metaTitle;
  334.         return $this;
  335.     }
  336.     public function getMetaDescription(): ?string
  337.     {
  338.         return $this->metaDescription;
  339.     }
  340.     public function setMetaDescription(?string $metaDescription): self
  341.     {
  342.         $this->metaDescription $metaDescription;
  343.         return $this;
  344.     }
  345.     public function getTag(): ?ArticleTag
  346.     {
  347.         return $this->tag;
  348.     }
  349.     public function setTag(?ArticleTag $tag): self
  350.     {
  351.         $this->tag $tag;
  352.         return $this;
  353.     }
  354.     public function getDateFin(): ?\DateTimeInterface
  355.     {
  356.         return $this->dateFin;
  357.     }
  358.     public function setDateFin(?\DateTimeInterface $dateFin): self
  359.     {
  360.         $this->dateFin $dateFin;
  361.         return $this;
  362.     }
  363.     public function getImageAlt(): ?string
  364.     {
  365.         return $this->imageAlt;
  366.     }
  367.     public function setImageAlt(string $imageAlt): self
  368.     {
  369.         $this->imageAlt $imageAlt;
  370.         return $this;
  371.     }
  372.     /**
  373.      * @return Collection|ArticleTagProduit[]
  374.      */
  375.     public function getTagProduits(): Collection
  376.     {
  377.         return $this->tagProduits;
  378.     }
  379.     public function addTagProduit(ArticleTagProduit $tagProduit): self
  380.     {
  381.         if (!$this->tagProduits->contains($tagProduit)) {
  382.             $this->tagProduits[] = $tagProduit;
  383.         }
  384.         return $this;
  385.     }
  386.     public function removeTagProduit(ArticleTagProduit $tagProduit): self
  387.     {
  388.         $this->tagProduits->removeElement($tagProduit);
  389.         return $this;
  390.     }
  391. }