<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\BlogPostRepository")
* @Vich\Uploadable
* @UniqueEntity("slug")
*/
class BlogPost
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var File|null
* @Assert\Image(
* mimeTypes="image/jpeg"
* )
* @Vich\UploadableField(mapping="blogpost_image", fileNameProperty="filename")
*/
private $imageFile;
/**
* @var string|null
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $filename;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Length (
* max = 50,
* maxMessage = "Le titre ne peut pas faire plus de {{ limit }} charactères"
* )
*/
private ?string $title = null;
/**
* @ORM\Column(type="string", length=255, unique=true)
* @Gedmo\Slug(fields={"title"})
*/
private ?string $slug = null;
/**
* @ORM\Column(type="string", length=2000, nullable=true)
*/
private ?string $description = null;
/**
* @ORM\Column(type="text")
*/
private ?string $body = null;
/**
* @ORM\Column(type="text")
*/
private $bodySecond;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Length (
* max = 50,
* maxMessage = "Le meta-title ne peut pas faire plus de {{ limit }} charactères"
* )
*/
private $metaTitle;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Length (
* max = 150,
* maxMessage = "La meta-description ne peut pas faire plus de {{ limit }} charactères"
* )
*/
private $metaDescription;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $metaCustom = null;
/**
* @ORM\Column(type="text", nullable=true)
* @Assert\Json(
* message = "You've entered an invalid Json."
* )
*/
private ?string $metaSchema = null;
/**
* @ORM\Column(type="string")
* @var string
*/
private $ctaLinkPath;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $keyword;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity="BlogAuthor", inversedBy="blogPosts")
* @Assert\NotNull
*/
private ?BlogAuthor $blogAuthor = null;
/**
* @ORM\Column(type="integer")
*/
private $readingTime;
/**
* @ORM\Column(type="boolean")
*/
private $isPillarPage;
/**
* @ORM\ManyToOne(targetEntity=BlogCategory::class, inversedBy="blogPosts")
*/
private $blogCategory;
public function __construct()
{
$this->createdAt = new \DateTime('now');
}
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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = strtolower($slug);
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getBody(): ?string
{
return $this->body;
}
public function setBody(string $body): self
{
$this->body = $body;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return null|File
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param null|File $imageFile
* @return BlogPost
*/
public function setImageFile($imageFile)
{
$this->imageFile = $imageFile;
if ($this->imageFile instanceof UploadedFile) {
$this->updatedAt = new \DateTime('now');
}
return $this;
}
/**
* @return null|string
*/
public function getFilename()
{
return $this->filename;
}
/**
* @param null|string $filename
* @return BlogPost
*/
public function setFilename($filename)
{
$this->filename = $filename;
return $this;
}
/**
* @return mixed
*/
public function getBodySecond()
{
return $this->bodySecond;
}
/**
* @param mixed $bodySecond
*/
public function setBodySecond($bodySecond)
{
$this->bodySecond = $bodySecond;
}
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 getMetaCustom(): ?string
{
return $this->metaCustom;
}
public function setMetaCustom(?string $metaCustom): self
{
$this->metaCustom = $metaCustom;
return $this;
}
public function getBlogAuthor(): ?BlogAuthor
{
return $this->blogAuthor;
}
public function setBlogAuthor(?BlogAuthor $blogAuthor): self
{
$this->blogAuthor = $blogAuthor;
return $this;
}
public function getReadingTime(): ?int
{
return $this->readingTime;
}
public function setReadingTime(int $readingTime): self
{
$this->readingTime = $readingTime;
return $this;
}
public function getCtaLinkPath(): ?string
{
return $this->ctaLinkPath;
}
public function setCtaLinkPath(string $ctaLinkPath): self
{
$this->ctaLinkPath = $ctaLinkPath;
return $this;
}
public function getKeyword(): ?string
{
return $this->keyword;
}
public function setKeyword(string $keyword): self
{
$this->keyword = $keyword;
return $this;
}
public function isIsPillarPage(): ?bool
{
return $this->isPillarPage;
}
public function setIsPillarPage(bool $isPillarPage): self
{
$this->isPillarPage = $isPillarPage;
return $this;
}
public function getBlogCategory(): ?BlogCategory
{
return $this->blogCategory;
}
public function setBlogCategory(?BlogCategory $blogCategory): self
{
$this->blogCategory = $blogCategory;
return $this;
}
public function getMetaSchema(): ?string
{
return $this->metaSchema;
}
public function setMetaSchema(?string $metaSchema): void
{
$this->metaSchema = $metaSchema;
}
}