<?php
namespace App\Entity;
use App\Repository\LandingPageRepository;
use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
use Cofondateur\SocleTechniqueBundle\Traits\SEOInterface;
use Cofondateur\SocleTechniqueBundle\Traits\SEOTrait;
use Cofondateur\SocleTechniqueBundle\Traits\SluggableInterface;
use Cofondateur\SocleTechniqueBundle\Traits\SluggableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
use App\Form\ParagraphFormType;
/**
* @ORM\Entity(repositoryClass=LandingPageRepository::class)
* @Uploadable()
*/
class LandingPage implements SEOInterface, SluggableInterface
{
use SEOTrait;
use SluggableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @CrudField(index=true, label="Titre")
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
* @CrudField(index=true, label="Titre sur la homepage")
*/
private $titleHp;
/**
* @ORM\Column(type="boolean", nullable=true)
* @CrudField(label="Affichage en homepage")
*/
private $displayHomepage;
/**
* @ORM\OneToMany(targetEntity=Paragraph::class, mappedBy="landingPage", cascade={"persist", "remove"})
* @CrudField(label="Paragraphes", formType=ParagraphFormType::class, tab="Paragraphes")
*/
private $paragraphs;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $iconName;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $iconSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $iconUpdatedAt;
/**
* @Vich\UploadableField(mapping="default", fileNameProperty="iconName", size="iconSize")
* @CrudField(label="Icone affiché sur la homepage")
*/
private $iconFile;
/**
* @ORM\Column(type="string", nullable=true)
* @CrudField(label="Alt")
*/
private $iconAlt;
public function __construct()
{
$this->paragraphs = new ArrayCollection();
}
public function __toString(): string
{
return $this->getId() ?? "N/A";
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getTitleHp(): ?string
{
return $this->titleHp;
}
public function setTitleHp(string $titleHp): self
{
$this->titleHp = $titleHp;
return $this;
}
public function isDisplayHomepage(): ?bool
{
return $this->displayHomepage;
}
public function setDisplayHomepage(?bool $displayHomepage): self
{
$this->displayHomepage = $displayHomepage;
return $this;
}
/**
* @return Collection<int, Paragraph>
*/
public function getParagraphs(): Collection
{
return $this->paragraphs;
}
public function addParagraph(Paragraph $paragraph): self
{
if (!$this->paragraphs->contains($paragraph)) {
$this->paragraphs[] = $paragraph;
$paragraph->setLandingPage($this);
}
return $this;
}
public function removeParagraph(Paragraph $paragraph): self
{
if ($this->paragraphs->removeElement($paragraph)) {
// set the owning side to null (unless already changed)
if ($paragraph->getLandingPage() === $this) {
$paragraph->setLandingPage(null);
}
}
return $this;
}
public function getIconName(): ?string
{
return $this->iconName;
}
public function setIconName(?string $iconName): self
{
$this->iconName = $iconName;
return $this;
}
public function getIconSize(): ?int
{
return $this->iconSize;
}
public function setIconSize(?int $iconSize): self
{
$this->iconSize = $iconSize;
return $this;
}
public function getIconUpdatedAt(): ?\DateTimeInterface
{
return $this->iconUpdatedAt;
}
public function setIconUpdatedAt(?\DateTimeInterface $iconUpdatedAt): self
{
$this->iconUpdatedAt = $iconUpdatedAt;
return $this;
}
public function getIconFile(): ?File
{
return $this->iconFile;
}
public function setIconFile(?File $iconFile): self
{
$this->iconFile = $iconFile;
if (null !== $this->iconFile) {
$this->iconUpdatedAt = new \DateTimeImmutable();
}
return $this;
}
public function getIconAlt(): ?string
{
return $this->iconAlt;
}
public function setIconAlt(?string $iconAlt): self
{
$this->iconAlt = $iconAlt;
return $this;
}
}