<?php
namespace App\Entity\Website\Cms;
use App\Entity\BaseEntity;
use App\Entity\Website\Website\Website;
use App\Repository\Website\Cms\ArticleRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Doctrine\Common\Collections\Collection;
#[ORM\Entity(repositoryClass: ArticleRepository::class)]
class Article extends BaseEntity
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[ORM\Column(type: 'guid', unique: true)]
private ?string $id = null;
#[ORM\Column(length: 200)]
private string $title;
#[ORM\Column(length: 150, unique: true)]
private string $slug;
#[ORM\Column(type: 'text')]
private string $content;
#[ORM\Column(length: 255, nullable: true)]
private ?string $excerpt = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $coverImage = null;
// SEO
#[ORM\Column(length: 255, nullable: true)]
private ?string $metaTitle = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $metaDescription = null;
#[ORM\Column(type: 'json', nullable: true)]
private ?array $metaKeywords = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $ogImage = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $canonicalUrl = null;
#[ORM\Column(nullable: true)]
private ?bool $noIndex = false;
#[ORM\Column(nullable: true)]
private ?bool $noFollow = false;
#[ORM\Column(length: 100, nullable: true)]
private ?string $schemaType = 'BlogPosting';
#[ORM\Column(type: 'json', nullable: true)]
private ?array $schemaData = null;
#[ORM\Column(type: 'json', nullable: true)]
private ?array $alternateLangs = null;
#[ORM\Column(type: 'float', nullable: true)]
private ?float $priorityInSitemap = 0.7;
#[ORM\Column(length: 50, nullable: true)]
private ?string $changeFrequency = 'weekly';
#[ORM\ManyToOne(inversedBy: 'articles')]
private ?Category $category = null;
#[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'articles')]
private Collection $tags;
#[ORM\ManyToOne(inversedBy: 'articles')]
#[ORM\JoinColumn(nullable: false)]
private ?Website $website = null;
public function __construct()
{
parent::__construct();
$this->tags = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): Article
{
$this->title = $title;
return $this;
}
public function getSlug(): string
{
return $this->slug;
}
public function setSlug(string $slug): Article
{
$this->slug = $slug;
return $this;
}
public function getContent(): string
{
return $this->content;
}
public function setContent(string $content): Article
{
$this->content = $content;
return $this;
}
public function getExcerpt(): ?string
{
return $this->excerpt;
}
public function setExcerpt(?string $excerpt): Article
{
$this->excerpt = $excerpt;
return $this;
}
public function getCoverImage(): ?string
{
return $this->coverImage;
}
public function setCoverImage(?string $coverImage): Article
{
$this->coverImage = $coverImage;
return $this;
}
public function getMetaTitle(): ?string
{
return $this->metaTitle;
}
public function setMetaTitle(?string $metaTitle): Article
{
$this->metaTitle = $metaTitle;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): Article
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getMetaKeywords(): ?array
{
return $this->metaKeywords;
}
public function setMetaKeywords(?array $metaKeywords): Article
{
$this->metaKeywords = $metaKeywords;
return $this;
}
public function getOgImage(): ?string
{
return $this->ogImage;
}
public function setOgImage(?string $ogImage): Article
{
$this->ogImage = $ogImage;
return $this;
}
public function getCanonicalUrl(): ?string
{
return $this->canonicalUrl;
}
public function setCanonicalUrl(?string $canonicalUrl): Article
{
$this->canonicalUrl = $canonicalUrl;
return $this;
}
public function getNoIndex(): ?bool
{
return $this->noIndex;
}
public function setNoIndex(?bool $noIndex): Article
{
$this->noIndex = $noIndex;
return $this;
}
public function getNoFollow(): ?bool
{
return $this->noFollow;
}
public function setNoFollow(?bool $noFollow): Article
{
$this->noFollow = $noFollow;
return $this;
}
public function getSchemaType(): ?string
{
return $this->schemaType;
}
public function setSchemaType(?string $schemaType): Article
{
$this->schemaType = $schemaType;
return $this;
}
public function getSchemaData(): ?array
{
return $this->schemaData;
}
public function setSchemaData(?array $schemaData): Article
{
$this->schemaData = $schemaData;
return $this;
}
public function getAlternateLangs(): ?array
{
return $this->alternateLangs;
}
public function setAlternateLangs(?array $alternateLangs): Article
{
$this->alternateLangs = $alternateLangs;
return $this;
}
public function getPriorityInSitemap(): ?float
{
return $this->priorityInSitemap;
}
public function setPriorityInSitemap(?float $priorityInSitemap): Article
{
$this->priorityInSitemap = $priorityInSitemap;
return $this;
}
public function getChangeFrequency(): ?string
{
return $this->changeFrequency;
}
public function setChangeFrequency(?string $changeFrequency): Article
{
$this->changeFrequency = $changeFrequency;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): static
{
$this->category = $category;
return $this;
}
/**
* @return Collection<int, Tag>
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tag $tag): static
{
if (!$this->tags->contains($tag)) {
$this->tags->add($tag);
}
return $this;
}
public function removeTag(Tag $tag): static
{
$this->tags->removeElement($tag);
return $this;
}
public function getWebsite(): ?Website
{
return $this->website;
}
public function setWebsite(?Website $website): static
{
$this->website = $website;
return $this;
}
}