<?php
namespace App\Entity\Site;
use App\Repository\Site\LocaleMereRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=LocaleMereRepository::class)
* @UniqueEntity("seoUrl")
* @Vich\Uploadable
*/
class LocaleMere
{
/**
* @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;
//---------------------------------------------------------
// VICHUPLOADER propriété START
//---------------------------------------------------------
/**
* @ORM\Column(type="text", nullable=true)
*/
private $imageEnTete;
/**
* @Vich\UploadableField(mapping="locale_mere", fileNameProperty="imageEnTete")
* @Assert\File(
* maxSize = "2M",
* maxSizeMessage = "La taille maximale autorisée et de {{ limit }} {{ suffix }}, {{ name }} fait {{ size }} {{ suffix }}.",
* mimeTypes = {"image/jpg", "image/jpeg", "image/png", "image/svg"},
* 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="string", length=255, nullable=true)
*/
private $metaTitle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $metaDescription;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imageAlt;
/**
* @ORM\Column(type="text")
*/
private $contenu1;
/**
* @ORM\Column(type="text")
*/
private $contenu2;
/**
* @ORM\Column(type="string", length=255)
*/
private $latitude;
/**
* @ORM\Column(type="string", length=255)
*/
private $longitude;
/**
* @ORM\OneToMany(targetEntity=LocaleFille::class, mappedBy="localeMere", orphanRemoval=true, cascade={"all"})
*/
private $localeFilles;
public function __construct()
{
$this->date = new \DateTime('now');
$this->localeFilles = new ArrayCollection();
}
public function __toString()
{
return $this->getTitre();
}
//---------------------------------------------------------
// 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 getImageEnTete(): ?string
{
return $this->imageEnTete;
}
public function setImageEnTete(?string $imageEnTete): self
{
$this->imageEnTete = $imageEnTete;
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 getImageAlt(): ?string
{
return $this->imageAlt;
}
public function setImageAlt(?string $imageAlt): self
{
$this->imageAlt = $imageAlt;
return $this;
}
public function getContenu1(): ?string
{
return $this->contenu1;
}
public function setContenu1(string $contenu1): self
{
$this->contenu1 = $contenu1;
return $this;
}
public function getContenu2(): ?string
{
return $this->contenu2;
}
public function setContenu2(string $contenu2): self
{
$this->contenu2 = $contenu2;
return $this;
}
public function getLatitude(): ?string
{
return $this->latitude;
}
public function setLatitude(string $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?string
{
return $this->longitude;
}
public function setLongitude(string $longitude): self
{
$this->longitude = $longitude;
return $this;
}
/**
* @return Collection|LocaleFille[]
*/
public function getLocaleFilles(): Collection
{
return $this->localeFilles;
}
public function addLocaleFille(LocaleFille $localeFille): self
{
if (!$this->localeFilles->contains($localeFille)) {
$this->localeFilles[] = $localeFille;
$localeFille->setLocaleMere($this);
}
return $this;
}
public function removeLocaleFille(LocaleFille $localeFille): self
{
if ($this->localeFilles->removeElement($localeFille)) {
// set the owning side to null (unless already changed)
if ($localeFille->getLocaleMere() === $this) {
$localeFille->setLocaleMere(null);
}
}
return $this;
}
}