<?php
/**
* This file is part of Symfony Keen Template Project.
* (c) 2021 One AM SRL
*/
namespace App\Entity;
use App\Entity\AboutConfiguration\AboutConfigurationCallToAction;
use App\Entity\Component\ComponentCallToAction;
use App\Entity\ComponentConfiguration\ComponentConfigurationCallToAction;
use App\Entity\Embeddable\File\CoverFile;
use App\Entity\Embeddable\File\DocumentFile;
use App\Entity\Page\PageCallToAction;
use App\Entity\Product\ProductCallToAction;
use App\Repository\CallToActionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\String\Slugger\AsciiSlugger;
#[ORM\Entity(repositoryClass: CallToActionRepository::class)]
class CallToAction implements SluggableInterface
{
use SluggableTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['ajax'])]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['ajax'])]
private $title;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['ajax'])]
private $description;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $tag;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $url;
#[ORM\Embedded(class: CoverFile::class)]
#[Groups(['ajax'])]
private CoverFile $ctaCover;
#[ORM\Embedded(class: CoverFile::class)]
#[Groups(['ajax'])]
private CoverFile $cover;
#[ORM\Embedded(class: DocumentFile::class)]
private DocumentFile $document;
#[ORM\Column(type: 'boolean')]
#[Groups(['ajax'])]
private $whiteRabbit;
#[ORM\OneToMany(mappedBy: 'callToAction', targetEntity: PageCallToAction::class)]
private $pageCallToActions;
#[ORM\OneToMany(mappedBy: 'callToAction', targetEntity: ProductCallToAction::class)]
private $productCallToActions;
#[ORM\OneToMany(mappedBy: 'callToAction', targetEntity: ComponentCallToAction::class)]
private $componentCallToActions;
#[ORM\OneToMany(mappedBy: 'callToAction', targetEntity: ComponentConfigurationCallToAction::class)]
private $componentConfigurationCallToActions;
#[ORM\OneToMany(mappedBy: 'callToAction', targetEntity: AboutConfigurationCallToAction::class)]
private $aboutConfigurationCallToActions;
public function __construct()
{
$this->cover = new CoverFile();
$this->ctaCover = new CoverFile();
$this->document = new DocumentFile();
$this->whiteRabbit = false;
$this->pageCallToActions = new ArrayCollection();
$this->productCallToActions = new ArrayCollection();
$this->componentCallToActions = new ArrayCollection();
$this->componentConfigurationCallToActions = new ArrayCollection();
$this->aboutConfigurationCallToActions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getTag(): ?string
{
return $this->tag;
}
public function setTag(?string $tag): self
{
$this->tag = $tag;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function shouldGenerateUniqueSlugs(): bool
{
return true;
}
public function generateSlugValue($values): string
{
return (new AsciiSlugger())->slug($this->getTitle(), $this->getSlugDelimiter())->lower()->toString();
}
public function getSluggableFields(): array
{
return ['title'];
}
public function getCover(): CoverFile
{
return $this->cover;
}
public function setCover(CoverFile $cover): self
{
$this->cover = $cover;
return $this;
}
public function getCtaCover(): CoverFile
{
return $this->ctaCover;
}
public function setCtaCover(CoverFile $ctaCover): self
{
$this->ctaCover = $ctaCover;
return $this;
}
public function getDocument(): DocumentFile
{
return $this->document;
}
public function setDocument(DocumentFile $document): self
{
$this->document = $document;
return $this;
}
public function isWhiteRabbit(): ?bool
{
return $this->whiteRabbit;
}
public function setWhiteRabbit(bool $whiteRabbit): self
{
$this->whiteRabbit = $whiteRabbit;
return $this;
}
/**
* @return Collection<int, PageCallToAction>
*/
public function getPageCallToActions(): Collection
{
return $this->pageCallToActions;
}
public function addPageCallToAction(PageCallToAction $pageCallToAction): self
{
if (!$this->pageCallToActions->contains($pageCallToAction)) {
$this->pageCallToActions[] = $pageCallToAction;
$pageCallToAction->setCallToAction($this);
}
return $this;
}
public function removePageCallToAction(PageCallToAction $pageCallToAction): self
{
if ($this->pageCallToActions->removeElement($pageCallToAction)) {
// set the owning side to null (unless already changed)
if ($pageCallToAction->getCallToAction() === $this) {
$pageCallToAction->setCallToAction(null);
}
}
return $this;
}
/**
* @return Collection<int, ComponentCallToAction>
*/
public function getComponentCallToActions(): Collection
{
return $this->componentCallToActions;
}
public function addComponentCallToAction(ComponentCallToAction $componentCallToAction): self
{
if (!$this->componentCallToActions->contains($componentCallToAction)) {
$this->componentCallToActions[] = $componentCallToAction;
$componentCallToAction->setCallToAction($this);
}
return $this;
}
public function removeComponentCallToAction(ComponentCallToAction $componentCallToAction): self
{
if ($this->componentCallToActions->removeElement($componentCallToAction)) {
// set the owning side to null (unless already changed)
if ($componentCallToAction->getCallToAction() === $this) {
$componentCallToAction->setCallToAction(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductCallToAction>
*/
public function getProductCallToActions(): Collection
{
return $this->productCallToActions;
}
public function addProductCallToAction(ProductCallToAction $productCallToAction): self
{
if (!$this->productCallToActions->contains($productCallToAction)) {
$this->productCallToActions[] = $productCallToAction;
$productCallToAction->setCallToAction($this);
}
return $this;
}
public function removeProductCallToAction(ProductCallToAction $productCallToAction): self
{
if ($this->productCallToActions->removeElement($productCallToAction)) {
// set the owning side to null (unless already changed)
if ($productCallToAction->getCallToAction() === $this) {
$productCallToAction->setCallToAction(null);
}
}
return $this;
}
/**
* @return Collection<int, ComponentConfigurationCallToAction>
*/
public function getComponentConfigurationCallToActions(): Collection
{
return $this->componentConfigurationCallToActions;
}
public function addComponentConfigurationCallToAction(ComponentConfigurationCallToAction $componentConfigurationCallToAction): self
{
if (!$this->componentConfigurationCallToActions->contains($componentConfigurationCallToAction)) {
$this->componentConfigurationCallToActions[] = $componentConfigurationCallToAction;
$componentConfigurationCallToAction->setCallToAction($this);
}
return $this;
}
public function removeComponentConfigurationCallToAction(ComponentConfigurationCallToAction $componentConfigurationCallToAction): self
{
if ($this->componentConfigurationCallToActions->removeElement($componentConfigurationCallToAction)) {
// set the owning side to null (unless already changed)
if ($componentConfigurationCallToAction->getCallToAction() === $this) {
$componentConfigurationCallToAction->setCallToAction(null);
}
}
return $this;
}
/**
* @return Collection<int, AboutConfigurationCallToAction>
*/
public function getAboutConfigurationCallToActions(): Collection
{
return $this->aboutConfigurationCallToActions;
}
public function addAboutConfigurationCallToAction(AboutConfigurationCallToAction $aboutConfigurationCallToAction): self
{
if (!$this->aboutConfigurationCallToActions->contains($aboutConfigurationCallToAction)) {
$this->aboutConfigurationCallToActions[] = $aboutConfigurationCallToAction;
$aboutConfigurationCallToAction->setCallToAction($this);
}
return $this;
}
public function removeAboutConfigurationCallToAction(AboutConfigurationCallToAction $aboutConfigurationCallToAction): self
{
if ($this->aboutConfigurationCallToActions->removeElement($aboutConfigurationCallToAction)) {
// set the owning side to null (unless already changed)
if ($aboutConfigurationCallToAction->getCallToAction() === $this) {
$aboutConfigurationCallToAction->setCallToAction(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->getTitle();
}
}