<?php
namespace App\Entity\Produit;
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\FamilleProduitRepository")
* @UniqueEntity("seoUrl")
* @Vich\Uploadable
*/
class FamilleProduit
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="boolean")
*/
private $actif;
/**
* @ORM\Column(type="integer")
*/
private $placement;
//---------------------------------------------------------
// VICHUPLOADER propriété START
//---------------------------------------------------------
/**
* @ORM\Column(type="text")
*/
private $urlImage;
/**
* @Vich\UploadableField(mapping="famille_produit_images", fileNameProperty="urlImage")
* @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="text", nullable=true)
*/
private $urlImageEntete;
/**
* @Vich\UploadableField(mapping="famille_produit_images", fileNameProperty="urlImageEntete")
* @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 $imageFileEntete;
/**
* @ORM\Column(type="date")
*/
private $date;
//---------------------------------------------------------
// VICHUPLOADER propriété END
//---------------------------------------------------------
/**
* @ORM\Column(type="string", length=255)
*/
private $designation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $configurateur;
/**
* @ORM\Column(type="string", length=255)
*/
private $seoUrl;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $metaTitle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $metaDescription;
/**
* @ORM\Column(type="text")
*/
private $navbarText;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Produit\SousFamille", mappedBy="familleProduit")
* @ORM\OrderBy({"placement" = "ASC"})
*/
private $sousFamilles;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $descriptionFin;
public function __construct()
{
$this->sousFamilles = new ArrayCollection();
$this->date = new \DateTime('now');
}
public function __toString()
{
return $this->getDesignation();
}
//---------------------------------------------------------
// VICHUPLOADER méthode START
//---------------------------------------------------------
public function setImageFile(File $urlImage = null)
{
$this->imageFile = $urlImage;
// 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 ($urlImage) {
// if 'updatedAt' is not defined in your entity, use another property
$this->date = new \DateTime('now');
}
}
public function getImageFile()
{
return $this->imageFile;
}
public function setImageFileEntete(File $urlImageEntete = null)
{
$this->imageFileEntete = $urlImageEntete;
// 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 ($urlImageEntete) {
// if 'updatedAt' is not defined in your entity, use another property
$this->date = new \DateTime('now');
}
}
public function getImageFileEntete()
{
return $this->imageFileEntete;
}
public function getUrlImageEntete(): ?string
{
return $this->urlImageEntete;
}
public function setUrlImageEntete(?string $urlImageEntete): self
{
$this->urlImageEntete = $urlImageEntete;
return $this;
}
//---------------------------------------------------------
// VICHUPLOADER méthode END
//---------------------------------------------------------
public function getId(): ?int
{
return $this->id;
}
public function getUrlImage(): ?string
{
return $this->urlImage;
}
public function setUrlImage(?string $urlImage): self
{
$this->urlImage = $urlImage;
return $this;
}
public function getActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): self
{
$this->actif = $actif;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getPlacement(): ?int
{
return $this->placement;
}
public function setPlacement(int $placement): self
{
$this->placement = $placement;
return $this;
}
public function getDesignation(): ?string
{
return $this->designation;
}
public function setDesignation(string $designation): self
{
$this->designation = $designation;
return $this;
}
public function getConfigurateur(): ?string
{
return $this->configurateur;
}
public function setConfigurateur(?string $configurateur): self
{
$this->configurateur = $configurateur;
return $this;
}
public function getSeoUrl(): ?string
{
return $this->seoUrl;
}
public function setSeoUrl(string $seoUrl): self
{
$this->seoUrl = $seoUrl;
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 getNavbarText(): ?string
{
return $this->navbarText;
}
public function setNavbarText(string $navbarText): self
{
$this->navbarText = $navbarText;
return $this;
}
/**
* @return Collection|SousFamille[]
*/
public function getSousFamilles(): Collection
{
return $this->sousFamilles;
}
public function addSousFamille(SousFamille $sousFamille): self
{
if (!$this->sousFamilles->contains($sousFamille)) {
$this->sousFamilles[] = $sousFamille;
$sousFamille->setFamilleProduit($this);
}
return $this;
}
public function removeSousFamille(SousFamille $sousFamille): self
{
if ($this->sousFamilles->contains($sousFamille)) {
$this->sousFamilles->removeElement($sousFamille);
// set the owning side to null (unless already changed)
if ($sousFamille->getFamilleProduit() === $this) {
$sousFamille->setFamilleProduit(null);
}
}
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getDescriptionFin(): ?string
{
return $this->descriptionFin;
}
public function setDescriptionFin(?string $descriptionFin): self
{
$this->descriptionFin = $descriptionFin;
return $this;
}
}