<?php
namespace App\Entity\Website\Cms;
use App\Entity\BaseEntity;
use App\Entity\Website\Website\Website;
use App\Repository\Website\Cms\CategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
class Category extends BaseEntity
{
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private ?string $id = null;
#[ORM\Column(length: 100)]
private string $name;
#[ORM\Column(length: 150, unique: true)]
private string $slug;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
// SEO
#[ORM\Column(length: 255, nullable: true)]
private ?string $metaTitle = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $metaDescription = 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 = 'CollectionPage';
#[ORM\Column(type: 'json', nullable: true)]
private ?array $schemaData = null;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Article::class)]
private Collection $articles;
#[ORM\ManyToOne(inversedBy: 'categories')]
#[ORM\JoinColumn(nullable: false)]
private ?Website $website = null;
public function __construct()
{
parent::__construct();
$this->articles = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): Category
{
$this->name = $name;
return $this;
}
public function getSlug(): string
{
return $this->slug;
}
public function setSlug(string $slug): Category
{
$this->slug = $slug;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): Category
{
$this->description = $description;
return $this;
}
public function getMetaTitle(): ?string
{
return $this->metaTitle;
}
public function setMetaTitle(?string $metaTitle): Category
{
$this->metaTitle = $metaTitle;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): Category
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getOgImage(): ?string
{
return $this->ogImage;
}
public function setOgImage(?string $ogImage): Category
{
$this->ogImage = $ogImage;
return $this;
}
public function getCanonicalUrl(): ?string
{
return $this->canonicalUrl;
}
public function setCanonicalUrl(?string $canonicalUrl): Category
{
$this->canonicalUrl = $canonicalUrl;
return $this;
}
public function getNoIndex(): ?bool
{
return $this->noIndex;
}
public function setNoIndex(?bool $noIndex): Category
{
$this->noIndex = $noIndex;
return $this;
}
public function getNoFollow(): ?bool
{
return $this->noFollow;
}
public function setNoFollow(?bool $noFollow): Category
{
$this->noFollow = $noFollow;
return $this;
}
public function getSchemaType(): ?string
{
return $this->schemaType;
}
public function setSchemaType(?string $schemaType): Category
{
$this->schemaType = $schemaType;
return $this;
}
public function getSchemaData(): ?array
{
return $this->schemaData;
}
public function setSchemaData(?array $schemaData): Category
{
$this->schemaData = $schemaData;
return $this;
}
/**
* @return Collection<int, Article>
*/
public function getArticles(): Collection
{
return $this->articles;
}
public function addArticle(Article $article): static
{
if (!$this->articles->contains($article)) {
$this->articles->add($article);
$article->setCategory($this);
}
return $this;
}
public function removeArticle(Article $article): static
{
if ($this->articles->removeElement($article)) {
// set the owning side to null (unless already changed)
if ($article->getCategory() === $this) {
$article->setCategory(null);
}
}
return $this;
}
public function getWebsite(): ?Website
{
return $this->website;
}
public function setWebsite(?Website $website): static
{
$this->website = $website;
return $this;
}
}