<?php
namespace App\Entity;
use App\Entity\Trait\BaseLocalizedWebspaceInterface;
use App\Entity\Trait\BaseLocalizedWebspaceTrait;
use App\Entity\Trait\RoutableTrait;
use App\Entity\Trait\SeoTrait;
use App\Entity\Trait\SocialTrait;
use App\Repository\ProductCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProductCategoryRepository::class)]
#[ORM\Table('app_product_categories')]
class ProductCategory implements BaseLocalizedWebspaceInterface
{
use BaseLocalizedWebspaceTrait;
use RoutableTrait;
use SeoTrait;
use SocialTrait;
public const RESOURCE_KEY = 'product_categories';
public const SOCIAL_OG_IMAGES_TABLE = 'app_product_category_social_og_images';
public const SOCIAL_TWITTER_IMAGES_TABLE = 'app_product_category_social_twitter_images';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(length: 50, unique: true, nullable: true)]
private ?string $slug = null;
#[ORM\Column(length: 255)]
private ?string $importId = null;
#[ORM\Column(nullable: true)]
private ?string $content = null;
#[ORM\ManyToMany(targetEntity: Product::class, fetch: 'EXTRA_LAZY')]
private Collection $referenceList;
public function __construct()
{
$this->referenceList = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function getImportId(): ?string
{
return $this->importId;
}
public function setImportId(string $importId): static
{
$this->importId = $importId;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): static
{
$this->content = $content;
return $this;
}
public function hasSlug(): bool
{
return $this->slug !== null;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): static
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getReferenceList(): Collection
{
return $this->referenceList;
}
public function addReferenceList(Product $referenceList): static
{
if (!$this->referenceList->contains($referenceList)) {
$this->referenceList->add($referenceList);
$referenceList->addCategory($this);
}
return $this;
}
public function removeReferenceList(Product $referenceList): static
{
if ($this->referenceList->removeElement($referenceList)) {
$referenceList->removeCategory($this);
}
return $this;
}
}