<?php
namespace App\Entity\Site;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Template\Row;
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;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass="App\Repository\Site\ArticleRepository")
* @UniqueEntity("seoUrl")
* @Vich\Uploadable
*/
class Article
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $placement;
/**
* @ORM\Column(type="string", length=255)
*/
private $titre;
/**
* @ORM\Column(type="text")
*/
private $resume;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Template\Row", mappedBy="article", orphanRemoval=true, cascade={"persist"})
* @ORM\OrderBy({"placement" = "ASC"})
*/
private $rows;
/**
* @ORM\Column(type="date")
*/
private $date;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $pdf;
//---------------------------------------------------------
// VICHUPLOADER propriété START
//---------------------------------------------------------
/**
* @ORM\Column(type="text")
*/
private $imageUrl;
/**
* @ORM\Column(type="text")
*/
private $imageBisUrl;
/**
* @ORM\Column(type="text")
*/
private $imageTerUrl;
/**
* @Vich\UploadableField(mapping="article_images", fileNameProperty="imageUrl")
* @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;
/**
* @Vich\UploadableField(mapping="article_images", fileNameProperty="imageBisUrl")
* @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 $imageBisFile;
/**
* @Vich\UploadableField(mapping="article_images", fileNameProperty="imageTerUrl")
* @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 $imageTerFile;
/**
* @ORM\Column(type="date")
*/
private $updatedAt;
//---------------------------------------------------------
// VICHUPLOADER propriété END
//---------------------------------------------------------
/**
* @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\ManyToOne(targetEntity="App\Entity\Site\ArticleTag", inversedBy="articles")
* @ORM\JoinColumn(nullable=false)
*/
private $tag;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $dateFin;
/**
* @ORM\Column(type="string", length=255)
*/
private $imageAlt;
/**
* @ORM\ManyToMany(targetEntity=ArticleTagProduit::class, inversedBy="articles")
*/
private $tagProduits;
public function __construct()
{
$this->rows = new ArrayCollection();
$this->date = new \DateTime('now');
$this->updatedAt = new \DateTime('now');
$this->tagProduits = 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->updatedAt = new \DateTime('now');
}
}
public function getImageFile()
{
return $this->imageFile;
}
public function setImageBisFile(File $url = null)
{
$this->imageBisFile = $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->updatedAt = new \DateTime('now');
}
}
public function getImageBisFile()
{
return $this->imageBisFile;
}
public function setImageTerFile(File $url = null)
{
$this->imageTerFile = $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->updatedAt = new \DateTime('now');
}
}
public function getImageTerFile()
{
return $this->imageTerFile;
}
//---------------------------------------------------------
// VICHUPLOADER méthode END
//---------------------------------------------------------
public function getId(): ?int
{
return $this->id;
}
public function getPlacement(): ?int
{
return $this->placement;
}
public function setPlacement(?int $placement): self
{
$this->placement = $placement;
return $this;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): self
{
$this->titre = $titre;
return $this;
}
public function getSousTitre(): ?string
{
return $this->sousTitre;
}
public function setSousTitre(?string $sousTitre): self
{
$this->sousTitre = $sousTitre;
return $this;
}
public function getResume(): ?string
{
return $this->resume;
}
public function setResume(string $resume): self
{
$this->resume = $resume;
return $this;
}
public function getPdf(): ?string
{
return $this->pdf;
}
public function setPdf(?string $pdf): self
{
$this->pdf = $pdf;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getSeoUrl(): ?string
{
return $this->seoUrl;
}
public function setSeoUrl(string $seoUrl): self
{
$this->seoUrl = $seoUrl;
return $this;
}
public function getImageUrl(): ?string
{
return $this->imageUrl;
}
public function setImageUrl(?string $imageUrl): self
{
$this->imageUrl = $imageUrl;
return $this;
}
public function getImageBisUrl(): ?string
{
return $this->imageBisUrl;
}
public function setImageBisUrl(?string $imageBisUrl): self
{
$this->imageBisUrl = $imageBisUrl;
return $this;
}
public function getImageTerUrl(): ?string
{
return $this->imageTerUrl;
}
public function setImageTerUrl(?string $imageTerUrl): self
{
$this->imageTerUrl = $imageTerUrl;
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->setArticle($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->getArticle() === $this) {
$row->setArticle(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 getTag(): ?ArticleTag
{
return $this->tag;
}
public function setTag(?ArticleTag $tag): self
{
$this->tag = $tag;
return $this;
}
public function getDateFin(): ?\DateTimeInterface
{
return $this->dateFin;
}
public function setDateFin(?\DateTimeInterface $dateFin): self
{
$this->dateFin = $dateFin;
return $this;
}
public function getImageAlt(): ?string
{
return $this->imageAlt;
}
public function setImageAlt(string $imageAlt): self
{
$this->imageAlt = $imageAlt;
return $this;
}
/**
* @return Collection|ArticleTagProduit[]
*/
public function getTagProduits(): Collection
{
return $this->tagProduits;
}
public function addTagProduit(ArticleTagProduit $tagProduit): self
{
if (!$this->tagProduits->contains($tagProduit)) {
$this->tagProduits[] = $tagProduit;
}
return $this;
}
public function removeTagProduit(ArticleTagProduit $tagProduit): self
{
$this->tagProduits->removeElement($tagProduit);
return $this;
}
}