<?php
namespace App\Entity;
use App\Entity\Traits\UpdatableInterface;
use App\Entity\Traits\UpdatableTrait;
use App\Repository\LandingPageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Vich\Uploadable
* @ORM\Entity(repositoryClass=LandingPageRepository::class)
*/
class LandingPage implements UpdatableInterface
{
use UpdatableTrait;
public function __toString()
{
return "#" . $this->id . " " . $this->getTitle();
}
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $metaTitle;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $metaDescription;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @Assert\NotBlank()
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $slug;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $intro;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contentTitle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $contentIntro;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Vich\UploadableField(mapping="landingPage", fileNameProperty="landingPageFileName", size="landingPageFileSize")
* @Assert\Expression("this.getLandingPageFile() or this.getLandingPageFileName()", message = "Veuillez sélectionner un fichier")
* @Assert\File(
* maxSize = "1200k"
* )
*
* @var File
*/
private $landingPageFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $landingPageFileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var integer
*/
private $landingPageFileSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $landingPageFileUpdatedAt;
/**
* @ORM\OneToMany(targetEntity=ProductParagraph::class, mappedBy="landingPage")
*/
private $productParagraphs;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $locale;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $h1;
public function __construct()
{
$this->productParagraphs = new ArrayCollection();
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
*/
public function setLandingPageFile(File $image = null)
{
$this->landingPageFile = $image;
if (null !== $image) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->landingPageFileUpdatedAt = new \DateTimeImmutable();
}
}
public function getLandingPageFile()
{
return $this->landingPageFile;
}
public function getLandingPageFileName(): ?string
{
return $this->landingPageFileName;
}
public function setLandingPageFileName(?string $landingPageFileName): self
{
$this->landingPageFileName = $landingPageFileName;
return $this;
}
public function getLandingPageFileSize(): ?int
{
return $this->landingPageFileSize;
}
public function setLandingPageFileSize(?int $landingPageFileSize): self
{
$this->landingPageFileSize = $landingPageFileSize;
return $this;
}
public function getLandingPageFileUpdatedAt(): ?\DateTimeInterface
{
return $this->landingPageFileUpdatedAt;
}
public function setLandingPageFileUpdatedAt(?\DateTimeInterface $landingPageFileUpdatedAt): self
{
$this->landingPageFileUpdatedAt = $landingPageFileUpdatedAt;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, ProductParagraph>
*/
public function getProductParagraphs(): Collection
{
return $this->productParagraphs;
}
public function addProductParagraph(ProductParagraph $productParagraph): self
{
if (!$this->productParagraphs->contains($productParagraph)) {
$this->productParagraphs[] = $productParagraph;
$productParagraph->setLandingPage($this);
}
return $this;
}
public function removeProductParagraph(ProductParagraph $productParagraph): self
{
if ($this->productParagraphs->removeElement($productParagraph)) {
// set the owning side to null (unless already changed)
if ($productParagraph->getLandingPage() === $this) {
$productParagraph->setLandingPage(null);
}
}
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getIntro(): ?string
{
return $this->intro;
}
public function setIntro(?string $intro): self
{
$this->intro = $intro;
return $this;
}
public function getContentTitle(): ?string
{
return $this->contentTitle;
}
public function setContentTitle(?string $contentTitle): self
{
$this->contentTitle = $contentTitle;
return $this;
}
public function getContentIntro(): ?string
{
return $this->contentIntro;
}
public function setContentIntro(?string $contentIntro): self
{
$this->contentIntro = $contentIntro;
return $this;
}
public function getLocale(): ?string
{
return $this->locale;
}
public function setLocale(?string $locale): self
{
$this->locale = $locale;
return $this;
}
public function getMetaTitle(): ?string
{
return $this->metaTitle;
}
public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getH1(): ?string
{
return $this->h1;
}
public function setH1(?string $h1): self
{
$this->h1 = $h1;
return $this;
}
}