<?php
namespace App\Entity;
use App\Entity\Traits\LinkTrait;
use App\Entity\Traits\MetaTrait;
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 App\Repository\ServiceRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Entity\Traits\ImageUploadTrait;
use App\Entity\Traits\SitemapableTrait;
use App\Entity\Traits\TitleAndContentTrait;
use App\Entity\Interfaces\DefaultLinkedEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Gedmo\Loggable
*/
#[ORM\Entity(repositoryClass: \App\Repository\ServiceRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'service')]
class Service 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(type: 'string', length: 255, nullable: true)]
private $cta_text;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $cta_link;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $cta_text2;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $cta_link2;
#[ORM\ManyToOne(targetEntity: Testimonial::class)]
private $testimonial;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $icon;
#[ORM\Column(type: 'string', length: 255)]
private $employer_or_employee;
#[ORM\ManyToOne(targetEntity: ServiceCategory::class, inversedBy: 'services')]
#[ORM\JoinColumn(nullable: false)]
private $category;
#[ORM\Column(type: 'boolean', nullable: false, options: ['default' => true])]
private bool $show_on_menu = true;
/**
* Override slug from LinkTrait to disable auto-update.
* Slug will only be auto-generated on create, but can be manually set.
*
* @Gedmo\Translatable
*
* @Gedmo\Versioned
*
* @Gedmo\Slug(fields={"title"}, separator="-", updatable=false)
*/
#[ORM\Column(length: 255, unique: true)]
private ?string $slug = null;
public function getId(): ?int
{
return $this->id;
}
// Required By The MetaTrait / DefaultLinkedEntity Interface
public function getLinkedPageId(): int
{
return 14;
}
public function getContent2(): ?string
{
return $this->content2;
}
public function setContent2(?string $content2): self
{
$this->content2 = $content2;
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 getCtaText2(): ?string
{
return $this->cta_text2;
}
public function setCtaText2(?string $cta_text2): self
{
$this->cta_text2 = $cta_text2;
return $this;
}
public function getCtaLink2(): ?string
{
return $this->cta_link2;
}
public function setCtaLink2(?string $cta_link2): self
{
$this->cta_link2 = $cta_link2;
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;
}
public function getEmployerOrEmployee(): ?string
{
return $this->employer_or_employee;
}
public function setEmployerOrEmployee(string $employer_or_employee): self
{
$this->employer_or_employee = $employer_or_employee;
return $this;
}
public function getCategory(): ?ServiceCategory
{
return $this->category;
}
public function setCategory(?ServiceCategory $category): self
{
$this->category = $category;
return $this;
}
public function getShowOnMenu(): ?bool
{
return $this->show_on_menu;
}
public function setShowOnMenu(bool $show_on_menu): self
{
$this->show_on_menu = $show_on_menu;
return $this;
}
public function getSitemapRouteParams(): array
{
return ['slug' => $this->getSlug()];
}
public function isIncludedInSitemap(): bool
{
return $this->isActive() &&
! $this->isDeleted();
}
/**
* Override setSlug from LinkTrait to allow manual setting.
* If empty string is provided, set to null to allow auto-generation on create.
*/
public function setSlug(?string $slug): void
{
// Convert empty string to null so Gedmo can auto-generate on create
$this->slug = ($slug === '' || $slug === null) ? null : $slug;
}
}