src/Entity/LandingPage.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LandingPageRepository;
  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 Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\HttpFoundation\File\File;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
  15. use App\Form\ActualiteParagraphFormType;
  16. /**
  17.  * @ORM\Entity(repositoryClass=LandingPageRepository::class)
  18.  * @Uploadable()
  19.  */
  20. class LandingPage implements SEOInterfaceSluggableInterface
  21. {
  22.     
  23.     use SEOTrait;
  24.         
  25.     use SluggableTrait;
  26.     
  27.     /**
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     private int $id;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      * @CrudField(index=true, label="Titre")
  36.      */
  37.     private string $title;
  38.     /**
  39.      * @ORM\Column(type="datetime_immutable")
  40.      */
  41.     private $createdAt;
  42.     /**
  43.      * @ORM\Column(type="string")
  44.      */
  45.     private $coverName;
  46.     /**
  47.      * @ORM\Column(type="integer")
  48.      */
  49.     private $coverSize;
  50.     /**
  51.      * @ORM\Column(type="datetime", nullable=true)
  52.      */
  53.     private $coverUpdatedAt;
  54.     /**
  55.      * @Vich\UploadableField(mapping="default", fileNameProperty="coverName", size="coverSize")
  56.      * @CrudField(label="Visuel principal (bandeau top)")
  57.      */
  58.     private $coverFile;
  59.     /**
  60.      * @ORM\Column(type="string", nullable=true)
  61.      * @CrudField(label="Alt")
  62.      */
  63.     private $coverAlt;
  64.     /**
  65.      * @ORM\OneToMany(targetEntity=ActualiteParagraph::class, mappedBy="landingPage", cascade={"persist", "remove"})
  66.      * @CrudField(label="Paragraphes", formType=ActualiteParagraphFormType::class, tab="Paragraphes")
  67.      */
  68.     private $paragraphs;
  69.     /**
  70.      * @ORM\Column(type="text")
  71.      * @CrudField(label="Résumé de la page")
  72.      */
  73.     private $resumeOnPage;
  74.     public function __construct()
  75.     {
  76.         $this->paragraphs = new ArrayCollection();
  77.         $this->setCreatedAt(new \DateTimeImmutable());
  78.     }
  79.     public function __toString(): string
  80.     {
  81.         return $this->getId() ?? "N/A";
  82.     }
  83.     public function getId(): ?int
  84.     {
  85.         return $this->id;
  86.     }
  87.     public function getTitle(): ?string
  88.     {
  89.         return $this->title;
  90.     }
  91.     public function setTitle(string $title): self
  92.     {
  93.         $this->title $title;
  94.         return $this;
  95.     }
  96.     public function getCreatedAt(): ?\DateTimeImmutable
  97.     {
  98.         return $this->createdAt;
  99.     }
  100.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  101.     {
  102.         $this->createdAt $createdAt;
  103.         return $this;
  104.     }
  105.     public function getCoverName(): ?string
  106.     {
  107.         return $this->coverName;
  108.     }
  109.     public function setCoverName(string $coverName): self
  110.     {
  111.         $this->coverName $coverName;
  112.         return $this;
  113.     }
  114.     public function getCoverSize(): ?int
  115.     {
  116.         return $this->coverSize;
  117.     }
  118.     public function setCoverSize(int $coverSize): self
  119.     {
  120.         $this->coverSize $coverSize;
  121.         return $this;
  122.     }
  123.     public function getCoverUpdatedAt(): ?\DateTimeInterface
  124.     {
  125.         return $this->coverUpdatedAt;
  126.     }
  127.     public function setCoverUpdatedAt(?\DateTimeInterface $coverUpdatedAt): self
  128.     {
  129.         $this->coverUpdatedAt $coverUpdatedAt;
  130.         return $this;
  131.     }
  132.     public function getCoverFile(): ?File
  133.     {
  134.         return $this->coverFile;
  135.     }
  136.     public function setCoverFile(?File $coverFile): self
  137.     {
  138.         $this->coverFile $coverFile;
  139.         if (null !== $this->coverFile) {
  140.             $this->coverUpdatedAt = new \DateTimeImmutable();
  141.         }
  142.         return $this;
  143.     }
  144.     public function getCoverAlt(): ?string
  145.     {
  146.         return $this->coverAlt;
  147.     }
  148.     public function setCoverAlt(?string $coverAlt): self
  149.     {
  150.         $this->coverAlt $coverAlt;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return Collection<int, ActualiteParagraph>
  155.      */
  156.     public function getParagraphs(): Collection
  157.     {
  158.         return $this->paragraphs;
  159.     }
  160.     public function addParagraph(ActualiteParagraph $paragraph): self
  161.     {
  162.         if (!$this->paragraphs->contains($paragraph)) {
  163.             $this->paragraphs[] = $paragraph;
  164.             $paragraph->setLandingPage($this);
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeParagraph(ActualiteParagraph $paragraph): self
  169.     {
  170.         if ($this->paragraphs->removeElement($paragraph)) {
  171.             // set the owning side to null (unless already changed)
  172.             if ($paragraph->getLandingPage() === $this) {
  173.                 $paragraph->setLandingPage(null);
  174.             }
  175.         }
  176.         return $this;
  177.     }
  178.     public function getResumeOnPage(): ?string
  179.     {
  180.         return $this->resumeOnPage;
  181.     }
  182.     public function setResumeOnPage(string $resumeOnPage): self
  183.     {
  184.         $this->resumeOnPage $resumeOnPage;
  185.         return $this;
  186.     }
  187. }