<?php
namespace App\Entity;
use App\Entity\Traits\Timestampable;
use App\Repository\BlogRepository;
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: BlogRepository::class)]
#[ORM\Table(name: "blogs")]
#[ORM\HasLifecycleCallbacks]
/**
* @Vich\Uploadable
*/
class Blog
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Assert\NotBlank(message: 'Veuillez entrer un titre.')]
#[Assert\Length(min: 3, minMessage: '3 caractéres au minimum')]
private $title;
#[ORM\Column(type: 'text')]
#[Assert\NotBlank(message: 'Veuillez entrer une description.')]
#[Assert\Length(min: 10, minMessage: '10 caractéres au minimum')]
private $description;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="blog_image", fileNameProperty="imageName")
*
* @var File|null
*/
private $imageFile;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $imageName;
#[ORM\Column(type: 'boolean', nullable: true)]
private $online;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $fileName;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="blog_file", fileNameProperty="fileName")
*
* @var File|null
*/
private $fileFile;
#[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 $Slug;
#[ORM\Column(type: 'boolean')]
private $noIndex;
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
/**
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
// 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->setUpdatedAt(new \DateTimeImmutable);
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageName(?string $imageName): self
{
$this->imageName = $imageName;
return $this;
}
public function isOnline(): ?bool
{
return $this->online;
}
public function setOnline(?bool $online): self
{
$this->online = $online;
return $this;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName): self
{
$this->fileName = $fileName;
return $this;
}
/**
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $fileFile
*/
public function setFileFile(?File $fileFile = null): void
{
$this->fileFile = $fileFile;
if (null !== $fileFile) {
// 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->setUpdatedAt(new \DateTimeImmutable);
}
}
public function getFileFile(): ?File
{
return $this->fileFile;
}
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 getSlug(): ?string
{
return $this->Slug;
}
public function setSlug(?string $Slug): self
{
$this->Slug = $Slug;
return $this;
}
public function isNoIndex(): ?bool
{
return $this->noIndex;
}
public function setNoIndex(bool $noIndex): self
{
$this->noIndex = $noIndex;
return $this;
}
}