<?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\ProductFamilyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Sulu\Bundle\MediaBundle\Entity\Media;
#[ORM\Entity(repositoryClass: ProductFamilyRepository::class)]
#[ORM\Table('app_product_families')]
class ProductFamily implements BaseLocalizedWebspaceInterface
{
use BaseLocalizedWebspaceTrait;
use RoutableTrait;
use SeoTrait;
use SocialTrait;
public const RESOURCE_KEY = 'product_families';
public const SOCIAL_OG_IMAGES_TABLE = 'app_product_family_social_og_images';
public const SOCIAL_TWITTER_IMAGES_TABLE = 'app_product_family_social_twitter_images';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(length: 255)]
private ?string $importId = null;
#[ORM\Column(length: 50, unique: true, nullable: true)]
private ?string $slug = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $category = null;
#[ORM\ManyToOne(fetch: 'EXTRA_LAZY')]
#[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?Media $image = null;
#[ORM\ManyToMany(targetEntity: Product::class, fetch: 'EXTRA_LAZY')]
private Collection $referenceList;
#[ORM\ManyToOne(fetch: 'EXTRA_LAZY')]
#[ORM\JoinColumn(referencedColumnName: 'id', onDelete: 'SET NULL')]
private ?ProductCategory $productCategory = null;
public function __construct()
{
$this->socialInit();
$this->referenceList = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): static
{
$this->category = $category;
return $this;
}
public function getProductCategory(): ?ProductCategory
{
return $this->productCategory;
}
public function setProductCategory(?ProductCategory $productCategory): static
{
$this->productCategory = $productCategory;
return $this;
}
public function isProductCategory(): bool
{
return isset($this->productCategory);
}
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 hasSlug(): bool
{
return $this->slug !== null;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): static
{
$this->slug = $slug;
return $this;
}
public function getImage(): ?Media
{
return $this->image;
}
public function setImage(?Media $image): static
{
$this->image = $image;
return $this;
}
public function isImage(): bool
{
return isset($this->image);
}
/**
* @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;
}
}