<?php
namespace App\Entity;
use App\Entity\Traits\LinkTrait;
use App\Entity\Traits\MetaTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\ActiveTrait;
use App\Entity\Traits\DeleteTrait;
use App\Entity\Traits\SubTitleTrait;
use App\Entity\Traits\SortOrderTrait;
use App\Entity\Traits\TranslateTrait;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Entity\Traits\ImageUploadTrait;
use App\Entity\Traits\SitemapableTrait;
use App\Entity\Traits\TitleAndContentTrait;
use App\Repository\ServiceCategoryRepository;
use App\Entity\Interfaces\DefaultLinkedEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Gedmo\Loggable
*/
#[ORM\Entity(repositoryClass: ServiceCategoryRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'service_category')]
class ServiceCategory implements DefaultLinkedEntity
{
use TitleAndContentTrait;
use SubTitleTrait;
use ImageUploadTrait;
use SortOrderTrait;
use ActiveTrait;
use LinkTrait;
use MetaTrait;
use DeleteTrait;
use TimestampableEntity;
use TranslateTrait;
use SitemapableTrait;
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private readonly int $id;
#[ORM\Column(name: 'content2', type: 'text', nullable: true)]
private ?string $content2 = null;
#[ORM\Column(name: 'content3', type: 'text', nullable: true)]
private ?string $content3 = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $cta_text;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $cta_link;
#[ORM\ManyToOne(targetEntity: Testimonial::class)]
private $testimonial;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $icon;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Service::class)]
private $services;
public function __construct()
{
$this->services = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
// Required By The MetaTrait / DefaultLinkedEntity Interface
public function getLinkedPageId(): int
{
// TODO - SET THIS CORRECTLY
return 13;
}
public function getContent2(): ?string
{
return $this->content2;
}
public function setContent2(?string $content2): self
{
$this->content2 = $content2;
return $this;
}
public function getContent3(): ?string
{
return $this->content3;
}
public function setContent3(?string $content3): self
{
$this->content3 = $content3;
return $this;
}
public function getCtaText(): ?string
{
return $this->cta_text;
}
public function setCtaText(?string $cta_text): self
{
$this->cta_text = $cta_text;
return $this;
}
public function getCtaLink(): ?string
{
return $this->cta_link;
}
public function setCtaLink(?string $cta_link): self
{
$this->cta_link = $cta_link;
return $this;
}
public function getTestimonial(): ?Testimonial
{
return $this->testimonial;
}
public function setTestimonial(?Testimonial $testimonial): self
{
$this->testimonial = $testimonial;
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
/**
* @return Collection<int, Service>
*/
public function getServices(): Collection
{
return $this->services;
}
public function addService(Service $service): self
{
if (!$this->services->contains($service)) {
$this->services[] = $service;
$service->setCategory($this);
}
return $this;
}
public function removeService(Service $service): self
{
if ($this->services->removeElement($service)) {
// set the owning side to null (unless already changed)
if ($service->getCategory() === $this) {
$service->setCategory(null);
}
}
return $this;
}
public function getSitemapRouteParams(): array
{
return ['slug' => $this->getSlug()];
}
public function isIncludedInSitemap(): bool
{
return $this->isActive() &&
! $this->isDeleted();
}
}