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\ParagraphFormType;
  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 $id;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      * @CrudField(index=true, label="Titre")
  36.      */
  37.     private $title;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      * @CrudField(index=true, label="Titre sur la homepage")
  41.      */
  42.     private $titleHp;
  43.     /**
  44.      * @ORM\Column(type="boolean", nullable=true)
  45.      * @CrudField(label="Affichage en homepage")
  46.      */
  47.     private $displayHomepage;
  48.     /**
  49.      * @ORM\OneToMany(targetEntity=Paragraph::class, mappedBy="landingPage", cascade={"persist", "remove"})
  50.      * @CrudField(label="Paragraphes", formType=ParagraphFormType::class, tab="Paragraphes")
  51.      */
  52.     private $paragraphs;
  53.     /**
  54.      * @ORM\Column(type="string", nullable=true)
  55.      */
  56.     private $iconName;
  57.     /**
  58.      * @ORM\Column(type="integer", nullable=true)
  59.      */
  60.     private $iconSize;
  61.     /**
  62.      * @ORM\Column(type="datetime", nullable=true)
  63.      */
  64.     private $iconUpdatedAt;
  65.     /**
  66.      * @Vich\UploadableField(mapping="default", fileNameProperty="iconName", size="iconSize")
  67.      * @CrudField(label="Icone affiché sur la homepage")
  68.      */
  69.     private $iconFile;
  70.     /**
  71.      * @ORM\Column(type="string", nullable=true)
  72.      * @CrudField(label="Alt")
  73.      */
  74.     private $iconAlt;
  75.     public function __construct()
  76.     {
  77.         $this->paragraphs = new ArrayCollection();
  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 getTitleHp(): ?string
  97.     {
  98.         return $this->titleHp;
  99.     }
  100.     public function setTitleHp(string $titleHp): self
  101.     {
  102.         $this->titleHp $titleHp;
  103.         return $this;
  104.     }
  105.     public function isDisplayHomepage(): ?bool
  106.     {
  107.         return $this->displayHomepage;
  108.     }
  109.     public function setDisplayHomepage(?bool $displayHomepage): self
  110.     {
  111.         $this->displayHomepage $displayHomepage;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, Paragraph>
  116.      */
  117.     public function getParagraphs(): Collection
  118.     {
  119.         return $this->paragraphs;
  120.     }
  121.     public function addParagraph(Paragraph $paragraph): self
  122.     {
  123.         if (!$this->paragraphs->contains($paragraph)) {
  124.             $this->paragraphs[] = $paragraph;
  125.             $paragraph->setLandingPage($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeParagraph(Paragraph $paragraph): self
  130.     {
  131.         if ($this->paragraphs->removeElement($paragraph)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($paragraph->getLandingPage() === $this) {
  134.                 $paragraph->setLandingPage(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139.     public function getIconName(): ?string
  140.     {
  141.         return $this->iconName;
  142.     }
  143.     public function setIconName(?string $iconName): self
  144.     {
  145.         $this->iconName $iconName;
  146.         return $this;
  147.     }
  148.     public function getIconSize(): ?int
  149.     {
  150.         return $this->iconSize;
  151.     }
  152.     public function setIconSize(?int $iconSize): self
  153.     {
  154.         $this->iconSize $iconSize;
  155.         return $this;
  156.     }
  157.     public function getIconUpdatedAt(): ?\DateTimeInterface
  158.     {
  159.         return $this->iconUpdatedAt;
  160.     }
  161.     public function setIconUpdatedAt(?\DateTimeInterface $iconUpdatedAt): self
  162.     {
  163.         $this->iconUpdatedAt $iconUpdatedAt;
  164.         return $this;
  165.     }
  166.     public function getIconFile(): ?File
  167.     {
  168.         return $this->iconFile;
  169.     }
  170.     public function setIconFile(?File $iconFile): self
  171.     {
  172.         $this->iconFile $iconFile;
  173.         if (null !== $this->iconFile) {
  174.             $this->iconUpdatedAt = new \DateTimeImmutable();
  175.         }
  176.         return $this;
  177.     }
  178.     public function getIconAlt(): ?string
  179.     {
  180.         return $this->iconAlt;
  181.     }
  182.     public function setIconAlt(?string $iconAlt): self
  183.     {
  184.         $this->iconAlt $iconAlt;
  185.         return $this;
  186.     }
  187. }