<?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\ActualiteParagraphFormType;
/**
* @ORM\Entity(repositoryClass=LandingPageRepository::class)
* @Uploadable()
*/
class LandingPage implements SEOInterface, SluggableInterface
{
use SEOTrait;
use SluggableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", length=255)
* @CrudField(index=true, label="Titre")
*/
private string $title;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\Column(type="string")
*/
private $coverName;
/**
* @ORM\Column(type="integer")
*/
private $coverSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $coverUpdatedAt;
/**
* @Vich\UploadableField(mapping="default", fileNameProperty="coverName", size="coverSize")
* @CrudField(label="Visuel principal (bandeau top)")
*/
private $coverFile;
/**
* @ORM\Column(type="string", nullable=true)
* @CrudField(label="Alt")
*/
private $coverAlt;
/**
* @ORM\OneToMany(targetEntity=ActualiteParagraph::class, mappedBy="landingPage", cascade={"persist", "remove"})
* @CrudField(label="Paragraphes", formType=ActualiteParagraphFormType::class, tab="Paragraphes")
*/
private $paragraphs;
/**
* @ORM\Column(type="text")
* @CrudField(label="Résumé de la page")
*/
private $resumeOnPage;
public function __construct()
{
$this->paragraphs = new ArrayCollection();
$this->setCreatedAt(new \DateTimeImmutable());
}
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 getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCoverName(): ?string
{
return $this->coverName;
}
public function setCoverName(string $coverName): self
{
$this->coverName = $coverName;
return $this;
}
public function getCoverSize(): ?int
{
return $this->coverSize;
}
public function setCoverSize(int $coverSize): self
{
$this->coverSize = $coverSize;
return $this;
}
public function getCoverUpdatedAt(): ?\DateTimeInterface
{
return $this->coverUpdatedAt;
}
public function setCoverUpdatedAt(?\DateTimeInterface $coverUpdatedAt): self
{
$this->coverUpdatedAt = $coverUpdatedAt;
return $this;
}
public function getCoverFile(): ?File
{
return $this->coverFile;
}
public function setCoverFile(?File $coverFile): self
{
$this->coverFile = $coverFile;
if (null !== $this->coverFile) {
$this->coverUpdatedAt = new \DateTimeImmutable();
}
return $this;
}
public function getCoverAlt(): ?string
{
return $this->coverAlt;
}
public function setCoverAlt(?string $coverAlt): self
{
$this->coverAlt = $coverAlt;
return $this;
}
/**
* @return Collection<int, ActualiteParagraph>
*/
public function getParagraphs(): Collection
{
return $this->paragraphs;
}
public function addParagraph(ActualiteParagraph $paragraph): self
{
if (!$this->paragraphs->contains($paragraph)) {
$this->paragraphs[] = $paragraph;
$paragraph->setLandingPage($this);
}
return $this;
}
public function removeParagraph(ActualiteParagraph $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 getResumeOnPage(): ?string
{
return $this->resumeOnPage;
}
public function setResumeOnPage(string $resumeOnPage): self
{
$this->resumeOnPage = $resumeOnPage;
return $this;
}
}