src/Entity/Actualite.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActualiteRepository;
  4. use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
  5. use Cofondateur\SocleTechniqueBundle\Traits\SEOInterface;
  6. use Cofondateur\SocleTechniqueBundle\Traits\SEOTrait;
  7. use Cofondateur\SocleTechniqueBundle\Traits\SluggableInterface;
  8. use Cofondateur\SocleTechniqueBundle\Traits\SluggableTrait;
  9. use DateTime;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\HttpFoundation\File\File;
  14. use Symfony\Component\Validator\Constraints\Date;
  15. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  16. use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
  17. use App\Form\ActualiteParagraphFormType;
  18. use App\Form\ActualiteHashtagFormType;
  19. use App\Form\ActualiteGalleriePhotoFormType;
  20. use App\Form\ActualiteGallerieVideoFormType;
  21. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  22. use Symfony\Component\Validator\Constraints as Assert;
  23. /**
  24.  * @ORM\Entity(repositoryClass=ActualiteRepository::class)
  25.  * @UniqueEntity(
  26.  *     fields={"slug"},
  27.  *     errorPath="slug",
  28.  *     message="Ce slug est déjà utilisé pour une autre actualité"
  29.  * )
  30.  * @Uploadable()
  31.  */
  32. class Actualite implements SEOInterfaceSluggableInterface
  33. {
  34.     
  35.     use SEOTrait;
  36.     use SluggableTrait;
  37.     
  38.     /**
  39.      * @ORM\Id
  40.      * @ORM\GeneratedValue
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     private $id;
  44.     /**
  45.      * @ORM\Column(type="string", length=255)
  46.      * @CrudField(index=true, label="Titre")
  47.      */
  48.     private $title;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=CategoryActualite::class, inversedBy="actualites")
  51.      * @ORM\JoinColumn(nullable=false)
  52.      * @CrudField(label="Catégorie de l'actualité")
  53.      */
  54.     private $category;
  55.     /**
  56.      * @ORM\ManyToMany(targetEntity=ActualiteHashtag::class, mappedBy="actualite", cascade={"persist", "remove"})
  57.      * @CrudField(label="Hashtags")
  58.      */
  59.     private $hashtags;
  60.     /**
  61.      * @ORM\Column(type="date")
  62.      * @CrudField(label="Date")
  63.      */
  64.     private $createdAt;
  65.     /**
  66.      * @ORM\Column(type="string")
  67.      */
  68.     private $coverName;
  69.     /**
  70.      * @ORM\Column(type="integer")
  71.      */
  72.     private $coverSize;
  73.     /**
  74.      * @ORM\Column(type="datetime", nullable=true)
  75.      */
  76.     private $coverUpdatedAt;
  77.     /**
  78.      * @Vich\UploadableField(mapping="default", fileNameProperty="coverName", size="coverSize")
  79.      * @CrudField(label="Visuel principal (bandeau top)")
  80.      */
  81.     private $coverFile;
  82.     /**
  83.      * @ORM\Column(type="string", nullable=true)
  84.      * @CrudField(label="Alt")
  85.      */
  86.     private $coverAlt;
  87.     /**
  88.      * @ORM\Column(type="text")
  89.      * @CrudField(label="Résumé sur les autres pages")
  90.      */
  91.     private $resumeOtherPage;
  92.     
  93.     /**
  94.      * @ORM\Column(type="text", nullable=true)
  95.      * @CrudField(label="Résumé sur la page")
  96.      */
  97.     private $resumeOnPage;
  98.     /**
  99.      * @ORM\OneToMany(targetEntity=ActualiteParagraph::class, mappedBy="actualite", cascade={"persist", "remove"})
  100.      * @CrudField(label="Paragraphes", formType=ActualiteParagraphFormType::class, tab="Paragraphes")
  101.      */
  102.     private $paragraphs;
  103.     /**
  104.      * @ORM\OneToMany(targetEntity=ActualiteGalleriePhoto::class, mappedBy="actualite", cascade={"persist", "remove"})
  105.      * @ORM\OrderBy({"position" = "ASC"})
  106.      * @CrudField(label="Photos de la galerie", formType=ActualiteGalleriePhotoFormType::class, tab="Galerie")
  107.      */
  108.     private $galeriePhotos;
  109.     /**
  110.      * @ORM\OneToMany(targetEntity=ActualiteGallerieVideo::class, mappedBy="actualite", cascade={"persist", "remove"})
  111.      * @ORM\OrderBy({"position" = "ASC"})
  112.      * @CrudField(label="Videos de la galerie", formType=ActualiteGallerieVideoFormType::class, tab="Galerie")
  113.      */
  114.     private $galerieVideos;
  115.     /**
  116.      * @ORM\ManyToMany(targetEntity=ReferencePublic::class, inversedBy="actualites")
  117.      * @CrudField(label="Références publiques", tab="Références")
  118.      */
  119.     private $referencesPublic;
  120.     /**
  121.      * @ORM\ManyToMany(targetEntity=ReferencePrive::class, inversedBy="actualites")
  122.      * @CrudField(label="Références privées", tab="Références")
  123.      */
  124.     private $referencesPrive;
  125.     /**
  126.      * @ORM\Column(type="boolean", nullable=true)
  127.      * @CrudField(label="Affiché sur le site", index=true)
  128.      */
  129.     private $published;
  130.     
  131.     public function __construct() {
  132.         $this->createdAt = new DateTime();
  133.         $this->paragraphs = new ArrayCollection();
  134.         $this->hashtags = new ArrayCollection();
  135.         $this->galeriePhotos = new ArrayCollection();
  136.         $this->galerieVideos = new ArrayCollection();
  137.         $this->referencesPublic = new ArrayCollection();
  138.         $this->referencesPrive = new ArrayCollection();
  139.     }
  140.     public function __toString(): string
  141.     {
  142.         return $this->getId() ?? "N/A";
  143.     }
  144.     public function getId(): ?int
  145.     {
  146.         return $this->id;
  147.     }
  148.     public function getCoverName(): ?string
  149.     {
  150.         return $this->coverName;
  151.     }
  152.     public function setCoverName(?string $coverName): self
  153.     {
  154.         $this->coverName $coverName;
  155.         return $this;
  156.     }
  157.     public function getCoverSize(): ?int
  158.     {
  159.         return $this->coverSize;
  160.     }
  161.     public function setCoverSize(?int $coverSize): self
  162.     {
  163.         $this->coverSize $coverSize;
  164.         return $this;
  165.     }
  166.     public function getCoverUpdatedAt(): ?\DateTimeInterface
  167.     {
  168.         return $this->coverUpdatedAt;
  169.     }
  170.     public function setCoverUpdatedAt(?\DateTimeInterface $coverUpdatedAt): self
  171.     {
  172.         $this->coverUpdatedAt $coverUpdatedAt;
  173.         return $this;
  174.     }
  175.     public function getCoverFile(): ?File
  176.     {
  177.         return $this->coverFile;
  178.     }
  179.     public function setCoverFile(?File $coverFile): self
  180.     {
  181.         $this->coverFile $coverFile;
  182.         if (null !== $this->coverFile) {
  183.             $this->coverUpdatedAt = new \DateTimeImmutable();
  184.         }
  185.         return $this;
  186.     }
  187.     public function getCoverAlt(): ?string
  188.     {
  189.         return $this->coverAlt;
  190.     }
  191.     public function setCoverAlt(?string $coverAlt): self
  192.     {
  193.         $this->coverAlt $coverAlt;
  194.         return $this;
  195.     }
  196.     public function getTitle(): ?string
  197.     {
  198.         return $this->title;
  199.     }
  200.     public function setTitle(string $title): self
  201.     {
  202.         $this->title $title;
  203.         return $this;
  204.     }
  205.     public function getCategory(): ?CategoryActualite
  206.     {
  207.         return $this->category;
  208.     }
  209.     public function setCategory(?CategoryActualite $category): self
  210.     {
  211.         $this->category $category;
  212.         return $this;
  213.     }
  214.     public function getResumeOnPage(): ?string
  215.     {
  216.         return $this->resumeOnPage;
  217.     }
  218.     public function setResumeOnPage(?string $resumeOnPage): self
  219.     {
  220.         $this->resumeOnPage $resumeOnPage;
  221.         return $this;
  222.     }
  223.     public function getResumeOtherPage(): ?string
  224.     {
  225.         return $this->resumeOtherPage;
  226.     }
  227.     public function setResumeOtherPage(string $resumeOtherPage): self
  228.     {
  229.         $this->resumeOtherPage $resumeOtherPage;
  230.         return $this;
  231.     }
  232.     public function getCreatedAt(): ?\DateTimeInterface
  233.     {
  234.         return $this->createdAt;
  235.     }
  236.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  237.     {
  238.         $this->createdAt $createdAt;
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, ActualiteParagraph>
  243.      */
  244.     public function getParagraphs(): Collection
  245.     {
  246.         return $this->paragraphs;
  247.     }
  248.     public function addParagraph(ActualiteParagraph $paragraph): self
  249.     {
  250.         if (!$this->paragraphs->contains($paragraph)) {
  251.             $this->paragraphs[] = $paragraph;
  252.             $paragraph->setActualite($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removeParagraph(ActualiteParagraph $paragraph): self
  257.     {
  258.         if ($this->paragraphs->removeElement($paragraph)) {
  259.             // set the owning side to null (unless already changed)
  260.             if ($paragraph->getActualite() === $this) {
  261.                 $paragraph->setActualite(null);
  262.             }
  263.         }
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection<int, ActualiteHashtag>
  268.      */
  269.     public function getHashtags(): Collection
  270.     {
  271.         return $this->hashtags;
  272.     }
  273.     public function addHashtag(ActualiteHashtag $hashtag): self
  274.     {
  275.         if (!$this->hashtags->contains($hashtag)) {
  276.             $this->hashtags[] = $hashtag;
  277.             $hashtag->addActualite($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeHashtag(ActualiteHashtag $hashtag): self
  282.     {
  283.         if ($this->hashtags->removeElement($hashtag)) {
  284.             $hashtag->removeActualite($this);
  285.         }
  286.         return $this;
  287.     }
  288.     /**
  289.      * @return Collection<int, ActualiteGalleriePhoto>
  290.      */
  291.     public function getGaleriePhotos(): Collection
  292.     {
  293.         return $this->galeriePhotos;
  294.     }
  295.     public function addGaleriePhoto(ActualiteGalleriePhoto $galeriePhoto): self
  296.     {
  297.         if (!$this->galeriePhotos->contains($galeriePhoto)) {
  298.             $this->galeriePhotos[] = $galeriePhoto;
  299.             $galeriePhoto->setActualite($this);
  300.         }
  301.         return $this;
  302.     }
  303.     public function removeGaleriePhoto(ActualiteGalleriePhoto $galeriePhoto): self
  304.     {
  305.         if ($this->galeriePhotos->removeElement($galeriePhoto)) {
  306.             // set the owning side to null (unless already changed)
  307.             if ($galeriePhoto->getActualite() === $this) {
  308.                 $galeriePhoto->setActualite(null);
  309.             }
  310.         }
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return Collection<int, ActualiteGallerieVideo>
  315.      */
  316.     public function getGalerieVideos(): Collection
  317.     {
  318.         return $this->galerieVideos;
  319.     }
  320.     public function addGalerieVideo(ActualiteGallerieVideo $galerieVideo): self
  321.     {
  322.         if (!$this->galerieVideos->contains($galerieVideo)) {
  323.             $this->galerieVideos[] = $galerieVideo;
  324.             $galerieVideo->setActualite($this);
  325.         }
  326.         return $this;
  327.     }
  328.     public function removeGalerieVideo(ActualiteGallerieVideo $galerieVideo): self
  329.     {
  330.         if ($this->galerieVideos->removeElement($galerieVideo)) {
  331.             // set the owning side to null (unless already changed)
  332.             if ($galerieVideo->getActualite() === $this) {
  333.                 $galerieVideo->setActualite(null);
  334.             }
  335.         }
  336.         return $this;
  337.     }
  338.     /**
  339.      * @return Collection<int, ReferencePublic>
  340.      */
  341.     public function getReferencesPublic(): Collection
  342.     {
  343.         return $this->referencesPublic;
  344.     }
  345.     public function addReferencesPublic(ReferencePublic $referencesPublic): self
  346.     {
  347.         if (!$this->referencesPublic->contains($referencesPublic)) {
  348.             $this->referencesPublic[] = $referencesPublic;
  349.         }
  350.         return $this;
  351.     }
  352.     public function removeReferencesPublic(ReferencePublic $referencesPublic): self
  353.     {
  354.         $this->referencesPublic->removeElement($referencesPublic);
  355.         return $this;
  356.     }
  357.     /**
  358.      * @return Collection<int, ReferencePrive>
  359.      */
  360.     public function getReferencesPrive(): Collection
  361.     {
  362.         return $this->referencesPrive;
  363.     }
  364.     public function addReferencesPrive(ReferencePrive $referencesPrive): self
  365.     {
  366.         if (!$this->referencesPrive->contains($referencesPrive)) {
  367.             $this->referencesPrive[] = $referencesPrive;
  368.         }
  369.         return $this;
  370.     }
  371.     public function removeReferencesPrive(ReferencePrive $referencesPrive): self
  372.     {
  373.         $this->referencesPrive->removeElement($referencesPrive);
  374.         return $this;
  375.     }
  376.     public function isPublished(): ?bool
  377.     {
  378.         return $this->published;
  379.     }
  380.     public function setPublished(?bool $published): self
  381.     {
  382.         $this->published $published;
  383.         return $this;
  384.     }
  385. }