<?php
namespace App\Entity\Template;
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 Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\Template\PageRepository")
* @UniqueEntity("seoUrl")
* @Vich\Uploadable
*/
class Page
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $titre;
/**
* @ORM\Column(type="string", length=255)
*/
private $seoUrl;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $sitemap;
//---------------------------------------------------------
// VICHUPLOADER propriété START
//---------------------------------------------------------
/**
* @ORM\Column(type="text", nullable=true)
*/
private $imageEnTete;
/**
* @Vich\UploadableField(mapping="template_page", fileNameProperty="imageEnTete")
* @Assert\File(
* maxSize = "350k",
* maxSizeMessage = "La taille maximale autorisée et de {{ limit }} {{ suffix }}, {{ name }} fait {{ size }} {{ suffix }}.",
* mimeTypes = {"image/jpg", "image/jpeg", "image/png", "image/svg", "image/webp"},
* mimeTypesMessage = "{{ name }} possède un format non pris en charge ({{ type }}), les formats autorisés sont : {{ types }}."
* )
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="date")
*/
private $date;
//---------------------------------------------------------
// VICHUPLOADER propriété END
//---------------------------------------------------------
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $navbarActive;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $navbarTopActive;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $footerActive;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $navbarSousMenu;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $navbarPosition;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $navbarTitre;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Template\Row", mappedBy="page", orphanRemoval=true, cascade={"all"})
* @ORM\OrderBy({"placement" = "ASC"})
*/
private $rows;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $metaTitle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $metaDescription;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isContactForm;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imageAlt;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $instantExpert;
public function __construct()
{
$this->rows = new ArrayCollection();
$this->date = new \DateTime('now');
}
//---------------------------------------------------------
// VICHUPLOADER méthode START
//---------------------------------------------------------
public function setImageFile(File $url = null)
{
$this->imageFile = $url;
// VERY IMPORTANT:
// 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
if ($url) {
// if 'updatedAt' is not defined in your entity, use another property
$this->date = new \DateTime('now');
}
}
public function getImageFile()
{
return $this->imageFile;
}
//---------------------------------------------------------
// VICHUPLOADER méthode END
//---------------------------------------------------------
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): self
{
$this->titre = $titre;
return $this;
}
public function getSeoUrl(): ?string
{
return $this->seoUrl;
}
public function setSeoUrl(string $seoUrl): self
{
$this->seoUrl = $seoUrl;
return $this;
}
public function getSitemap(): ?bool
{
return $this->sitemap;
}
public function setSitemap(?bool $sitemap): self
{
$this->sitemap = $sitemap;
return $this;
}
public function getImageEnTete(): ?string
{
return $this->imageEnTete;
}
public function setImageEnTete(?string $imageEnTete): self
{
$this->imageEnTete = $imageEnTete;
return $this;
}
public function getNavbarActive(): ?bool
{
return $this->navbarActive;
}
public function setNavbarActive(?bool $navbarActive): self
{
$this->navbarActive = $navbarActive;
return $this;
}
public function getNavbarTopActive(): ?bool
{
return $this->navbarTopActive;
}
public function setNavbarTopActive(?bool $navbarTopActive): self
{
$this->navbarTopActive = $navbarTopActive;
return $this;
}
public function getNavbarSousMenu(): ?bool
{
return $this->navbarSousMenu;
}
public function setNavbarSousMenu(?bool $navbarSousMenu): self
{
$this->navbarSousMenu = $navbarSousMenu;
return $this;
}
public function getFooterActive(): ?bool
{
return $this->footerActive;
}
public function setFooterActive(?bool $footerActive): self
{
$this->footerActive = $footerActive;
return $this;
}
public function getNavbarPosition(): ?int
{
return $this->navbarPosition;
}
public function setNavbarPosition(?int $navbarPosition): self
{
$this->navbarPosition = $navbarPosition;
return $this;
}
public function getNavbarTitre(): ?string
{
return $this->navbarTitre;
}
public function setNavbarTitre(?string $navbarTitre): self
{
$this->navbarTitre = $navbarTitre;
return $this;
}
/**
* @return Collection|Row[]
*/
public function getRows(): Collection
{
return $this->rows;
}
public function addRow(Row $row): self
{
if (!$this->rows->contains($row)) {
$this->rows[] = $row;
$row->setPage($this);
}
return $this;
}
public function removeRow(Row $row): self
{
if ($this->rows->contains($row)) {
$this->rows->removeElement($row);
// set the owning side to null (unless already changed)
if ($row->getPage() === $this) {
$row->setPage(null);
}
}
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 getIsContactForm(): ?bool
{
return $this->isContactForm;
}
public function setIsContactForm(?bool $isContactForm): self
{
$this->isContactForm = $isContactForm;
return $this;
}
public function getImageAlt(): ?string
{
return $this->imageAlt;
}
public function setImageAlt(?string $imageAlt): self
{
$this->imageAlt = $imageAlt;
return $this;
}
public function getInstantExpert(): ?bool
{
return $this->instantExpert;
}
public function setInstantExpert(?bool $instantExpert): self
{
$this->instantExpert = $instantExpert;
return $this;
}
}