src/Entity/LandingPage.php line 25

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\LandingPageSectionFormType;
  16. use App\Form\LandingPagePartnerFormType;
  17. use App\Form\LandingPageFaqFormType;
  18. /**
  19.  * @ORM\Entity(repositoryClass=LandingPageRepository::class)
  20.  * @Uploadable()
  21.  */
  22. class LandingPage implements SEOInterfaceSluggableInterface
  23. {
  24.     use SEOTrait;
  25.     use SluggableTrait;
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private int $id;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      * @CrudField(index=true, label="Titre (mettre entre étoiles pour rendre le titre avec le surlignage Exemple : 'ceci est en bleu *ceci est surligné*')")
  35.      */
  36.     private string $title;
  37.     /**
  38.      * @ORM\Column(type="text")
  39.      * @CrudField(label="Description", ckeditor=true)
  40.      */
  41.     private $description;
  42.     /**
  43.      * @ORM\Column(type="datetime_immutable")
  44.      */
  45.     private $createdAt;
  46.     /**
  47.      * @ORM\Column(type="string", nullable=true)
  48.      */
  49.     private $coverName;
  50.     /**
  51.      * @ORM\Column(type="integer", nullable=true)
  52.      */
  53.     private $coverSize;
  54.     /**
  55.      * @ORM\Column(type="datetime", nullable=true)
  56.      */
  57.     private $coverUpdatedAt;
  58.     /**
  59.      * @Vich\UploadableField(mapping="default", fileNameProperty="coverName", size="coverSize")
  60.      * @CrudField(label="Visuel principal (bandeau top)")
  61.      */
  62.     private $coverFile;
  63.     /**
  64.      * @ORM\Column(type="string", nullable=true)
  65.      * @CrudField(label="Alt")
  66.      */
  67.     private $coverAlt;
  68.     /**
  69.      * @ORM\Column(type="boolean")
  70.      * @CrudField(label="Publié", index=true)
  71.      */
  72.     private bool $published true;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=LandingPageSection::class, mappedBy="landingPage", cascade={"persist", "remove"}, orphanRemoval=true)
  75.      * @CrudField(label="Sections", formType=LandingPageSectionFormType::class, tab="Sections")
  76.      */
  77.     private $sections;
  78.     /**
  79.      * @ORM\Column(type="string", length=255, nullable=true)
  80.      * @CrudField(label="Sur-titre", tab="Citation")
  81.      */
  82.     private $citationOverTitle;
  83.     /**
  84.      * @ORM\Column(type="text", nullable=true)
  85.      * @CrudField(label="Citation (mettre entre étoiles pour rendre le titre avec le surlignage Exemple : 'ceci est en bleu *ceci est surligné*')", tab="Citation")
  86.      */
  87.     private $citation;
  88.     /**
  89.      * @ORM\OneToMany(targetEntity=LandingPagePartner::class, mappedBy="landingPage", cascade={"persist", "remove"}, orphanRemoval=true)
  90.      * @CrudField(label="Partenaires", formType=LandingPagePartnerFormType::class, tab="Partenaires")
  91.      */
  92.     private $partners;
  93.     /**
  94.      * @ORM\Column(type="string", length=255, nullable=true)
  95.      * @CrudField(label="Sur-titre de la section FAQ", tab="FAQ")
  96.      */
  97.     private $faqOverTitle;
  98.     /**
  99.      * @ORM\Column(type="string", length=255, nullable=true)
  100.      * @CrudField(label="Titre de la section FAQ", tab="FAQ")
  101.      */
  102.     private $faqTitle;
  103.     /**
  104.      * @ORM\OneToMany(targetEntity=LandingPageFaq::class, mappedBy="landingPage", cascade={"persist", "remove"}, orphanRemoval=true)
  105.      * @ORM\OrderBy({"position" = "ASC"})
  106.      * @CrudField(label="Questions / Réponses", formType=LandingPageFaqFormType::class, tab="FAQ")
  107.      */
  108.     private $faqItems;
  109.     public function isPublished(): bool
  110.     {
  111.         return $this->published;
  112.     }
  113.     public function setPublished(bool $published): self
  114.     {
  115.         $this->published $published;
  116.         return $this;
  117.     }
  118.     public function __construct()
  119.     {
  120.         $this->sections = new ArrayCollection();
  121.         $this->partners = new ArrayCollection();
  122.         $this->faqItems = new ArrayCollection();
  123.         $this->setCreatedAt(new \DateTimeImmutable());
  124.     }
  125.     public function __toString(): string
  126.     {
  127.         return (string) ($this->getId() ?? 'N/A');
  128.     }
  129.     public function getId(): ?int
  130.     {
  131.         return $this->id;
  132.     }
  133.     public function getTitle(): ?string
  134.     {
  135.         return $this->title;
  136.     }
  137.     public function getTitleWithoutStars(): ?string
  138.     {
  139.         return $this->title str_replace('*'''$this->title) : null;
  140.     }
  141.     public function setTitle(string $title): self
  142.     {
  143.         $this->title $title;
  144.         return $this;
  145.     }
  146.     public function getDescription(): ?string
  147.     {
  148.         return $this->description;
  149.     }
  150.     public function setDescription(string $description): self
  151.     {
  152.         $this->description $description;
  153.         return $this;
  154.     }
  155.     public function getCreatedAt(): ?\DateTimeImmutable
  156.     {
  157.         return $this->createdAt;
  158.     }
  159.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  160.     {
  161.         $this->createdAt $createdAt;
  162.         return $this;
  163.     }
  164.     public function getCoverName(): ?string
  165.     {
  166.         return $this->coverName;
  167.     }
  168.     public function setCoverName(?string $coverName): self
  169.     {
  170.         $this->coverName $coverName;
  171.         return $this;
  172.     }
  173.     public function getCoverSize(): ?int
  174.     {
  175.         return $this->coverSize;
  176.     }
  177.     public function setCoverSize(?int $coverSize): self
  178.     {
  179.         $this->coverSize $coverSize;
  180.         return $this;
  181.     }
  182.     public function getCoverUpdatedAt(): ?\DateTimeInterface
  183.     {
  184.         return $this->coverUpdatedAt;
  185.     }
  186.     public function setCoverUpdatedAt(?\DateTimeInterface $coverUpdatedAt): self
  187.     {
  188.         $this->coverUpdatedAt $coverUpdatedAt;
  189.         return $this;
  190.     }
  191.     public function getCoverFile(): ?File
  192.     {
  193.         return $this->coverFile;
  194.     }
  195.     public function setCoverFile(?File $coverFile): self
  196.     {
  197.         $this->coverFile $coverFile;
  198.         if (null !== $this->coverFile) {
  199.             $this->coverUpdatedAt = new \DateTimeImmutable();
  200.         }
  201.         return $this;
  202.     }
  203.     public function getCoverAlt(): ?string
  204.     {
  205.         return $this->coverAlt;
  206.     }
  207.     public function setCoverAlt(?string $coverAlt): self
  208.     {
  209.         $this->coverAlt $coverAlt;
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, LandingPageSection>
  214.      */
  215.     public function getSections(): Collection
  216.     {
  217.         return $this->sections;
  218.     }
  219.     public function addSection(LandingPageSection $section): self
  220.     {
  221.         if (!$this->sections->contains($section)) {
  222.             $this->sections[] = $section;
  223.             $section->setLandingPage($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeSection(LandingPageSection $section): self
  228.     {
  229.         if ($this->sections->removeElement($section)) {
  230.             if ($section->getLandingPage() === $this) {
  231.                 $section->setLandingPage(null);
  232.             }
  233.         }
  234.         return $this;
  235.     }
  236.     public function getCitationOverTitle(): ?string
  237.     {
  238.         return $this->citationOverTitle;
  239.     }
  240.     public function setCitationOverTitle(?string $citationOverTitle): self
  241.     {
  242.         $this->citationOverTitle $citationOverTitle;
  243.         return $this;
  244.     }
  245.     public function getCitation(): ?string
  246.     {
  247.         return $this->citation;
  248.     }
  249.     public function setCitation(?string $citation): self
  250.     {
  251.         $this->citation $citation;
  252.         return $this;
  253.     }
  254.     /**
  255.      * @return Collection<int, LandingPagePartner>
  256.      */
  257.     public function getPartners(): Collection
  258.     {
  259.         return $this->partners;
  260.     }
  261.     public function addPartner(LandingPagePartner $partner): self
  262.     {
  263.         if (!$this->partners->contains($partner)) {
  264.             $this->partners[] = $partner;
  265.             $partner->setLandingPage($this);
  266.         }
  267.         return $this;
  268.     }
  269.     public function removePartner(LandingPagePartner $partner): self
  270.     {
  271.         if ($this->partners->removeElement($partner)) {
  272.             if ($partner->getLandingPage() === $this) {
  273.                 $partner->setLandingPage(null);
  274.             }
  275.         }
  276.         return $this;
  277.     }
  278.     public function getFaqOverTitle(): ?string
  279.     {
  280.         return $this->faqOverTitle;
  281.     }
  282.     public function setFaqOverTitle(?string $faqOverTitle): self
  283.     {
  284.         $this->faqOverTitle $faqOverTitle;
  285.         return $this;
  286.     }
  287.     public function getFaqTitle(): ?string
  288.     {
  289.         return $this->faqTitle;
  290.     }
  291.     public function setFaqTitle(?string $faqTitle): self
  292.     {
  293.         $this->faqTitle $faqTitle;
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return Collection<int, LandingPageFaq>
  298.      */
  299.     public function getFaqItems(): Collection
  300.     {
  301.         return $this->faqItems;
  302.     }
  303.     public function addFaqItem(LandingPageFaq $faqItem): self
  304.     {
  305.         if (!$this->faqItems->contains($faqItem)) {
  306.             $this->faqItems[] = $faqItem;
  307.             $faqItem->setLandingPage($this);
  308.         }
  309.         return $this;
  310.     }
  311.     public function removeFaqItem(LandingPageFaq $faqItem): self
  312.     {
  313.         if ($this->faqItems->removeElement($faqItem)) {
  314.             if ($faqItem->getLandingPage() === $this) {
  315.                 $faqItem->setLandingPage(null);
  316.             }
  317.         }
  318.         return $this;
  319.     }
  320. }