src/Entity/CallToAction.php line 27

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of Symfony Keen Template Project.
  4.  * (c) 2021 One AM SRL
  5.  */
  6. namespace App\Entity;
  7. use App\Entity\AboutConfiguration\AboutConfigurationCallToAction;
  8. use App\Entity\Component\ComponentCallToAction;
  9. use App\Entity\ComponentConfiguration\ComponentConfigurationCallToAction;
  10. use App\Entity\Embeddable\File\CoverFile;
  11. use App\Entity\Embeddable\File\DocumentFile;
  12. use App\Entity\Page\PageCallToAction;
  13. use App\Entity\Product\ProductCallToAction;
  14. use App\Repository\CallToActionRepository;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\Common\Collections\Collection;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
  19. use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
  20. use Symfony\Component\Serializer\Annotation\Groups;
  21. use Symfony\Component\String\Slugger\AsciiSlugger;
  22. #[ORM\Entity(repositoryClassCallToActionRepository::class)]
  23. class CallToAction implements SluggableInterface
  24. {
  25.     use SluggableTrait;
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue]
  28.     #[ORM\Column(type'integer')]
  29.     #[Groups(['ajax'])]
  30.     private $id;
  31.     #[ORM\Column(type'string'length255)]
  32.     #[Groups(['ajax'])]
  33.     private $title;
  34.     #[ORM\Column(type'text'nullabletrue)]
  35.     #[Groups(['ajax'])]
  36.     private $description;
  37.     #[ORM\Column(type'string'length255nullabletrue)]
  38.     private $tag;
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     private $url;
  41.     #[ORM\Embedded(class: CoverFile::class)]
  42.     #[Groups(['ajax'])]
  43.     private CoverFile $ctaCover;
  44.     #[ORM\Embedded(class: CoverFile::class)]
  45.     #[Groups(['ajax'])]
  46.     private CoverFile $cover;
  47.     #[ORM\Embedded(class: DocumentFile::class)]
  48.     private DocumentFile $document;
  49.     #[ORM\Column(type'boolean')]
  50.     #[Groups(['ajax'])]
  51.     private $whiteRabbit;
  52.     #[ORM\OneToMany(mappedBy'callToAction'targetEntityPageCallToAction::class)]
  53.     private $pageCallToActions;
  54.     #[ORM\OneToMany(mappedBy'callToAction'targetEntityProductCallToAction::class)]
  55.     private $productCallToActions;
  56.     #[ORM\OneToMany(mappedBy'callToAction'targetEntityComponentCallToAction::class)]
  57.     private $componentCallToActions;
  58.     #[ORM\OneToMany(mappedBy'callToAction'targetEntityComponentConfigurationCallToAction::class)]
  59.     private $componentConfigurationCallToActions;
  60.     #[ORM\OneToMany(mappedBy'callToAction'targetEntityAboutConfigurationCallToAction::class)]
  61.     private $aboutConfigurationCallToActions;
  62.     public function __construct()
  63.     {
  64.         $this->cover = new CoverFile();
  65.         $this->ctaCover = new CoverFile();
  66.         $this->document = new DocumentFile();
  67.         $this->whiteRabbit false;
  68.         $this->pageCallToActions = new ArrayCollection();
  69.         $this->productCallToActions = new ArrayCollection();
  70.         $this->componentCallToActions = new ArrayCollection();
  71.         $this->componentConfigurationCallToActions = new ArrayCollection();
  72.         $this->aboutConfigurationCallToActions = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getTitle(): ?string
  79.     {
  80.         return $this->title;
  81.     }
  82.     public function setTitle(string $title): self
  83.     {
  84.         $this->title $title;
  85.         return $this;
  86.     }
  87.     public function getDescription(): ?string
  88.     {
  89.         return $this->description;
  90.     }
  91.     public function setDescription(?string $description): self
  92.     {
  93.         $this->description $description;
  94.         return $this;
  95.     }
  96.     public function getTag(): ?string
  97.     {
  98.         return $this->tag;
  99.     }
  100.     public function setTag(?string $tag): self
  101.     {
  102.         $this->tag $tag;
  103.         return $this;
  104.     }
  105.     public function getUrl(): ?string
  106.     {
  107.         return $this->url;
  108.     }
  109.     public function setUrl(?string $url): self
  110.     {
  111.         $this->url $url;
  112.         return $this;
  113.     }
  114.     public function shouldGenerateUniqueSlugs(): bool
  115.     {
  116.         return true;
  117.     }
  118.     public function generateSlugValue($values): string
  119.     {
  120.         return (new AsciiSlugger())->slug($this->getTitle(), $this->getSlugDelimiter())->lower()->toString();
  121.     }
  122.     public function getSluggableFields(): array
  123.     {
  124.         return ['title'];
  125.     }
  126.     public function getCover(): CoverFile
  127.     {
  128.         return $this->cover;
  129.     }
  130.     public function setCover(CoverFile $cover): self
  131.     {
  132.         $this->cover $cover;
  133.         return $this;
  134.     }
  135.     public function getCtaCover(): CoverFile
  136.     {
  137.         return $this->ctaCover;
  138.     }
  139.     public function setCtaCover(CoverFile $ctaCover): self
  140.     {
  141.         $this->ctaCover $ctaCover;
  142.         return $this;
  143.     }
  144.     public function getDocument(): DocumentFile
  145.     {
  146.         return $this->document;
  147.     }
  148.     public function setDocument(DocumentFile $document): self
  149.     {
  150.         $this->document $document;
  151.         return $this;
  152.     }
  153.     public function isWhiteRabbit(): ?bool
  154.     {
  155.         return $this->whiteRabbit;
  156.     }
  157.     public function setWhiteRabbit(bool $whiteRabbit): self
  158.     {
  159.         $this->whiteRabbit $whiteRabbit;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, PageCallToAction>
  164.      */
  165.     public function getPageCallToActions(): Collection
  166.     {
  167.         return $this->pageCallToActions;
  168.     }
  169.     public function addPageCallToAction(PageCallToAction $pageCallToAction): self
  170.     {
  171.         if (!$this->pageCallToActions->contains($pageCallToAction)) {
  172.             $this->pageCallToActions[] = $pageCallToAction;
  173.             $pageCallToAction->setCallToAction($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removePageCallToAction(PageCallToAction $pageCallToAction): self
  178.     {
  179.         if ($this->pageCallToActions->removeElement($pageCallToAction)) {
  180.             // set the owning side to null (unless already changed)
  181.             if ($pageCallToAction->getCallToAction() === $this) {
  182.                 $pageCallToAction->setCallToAction(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, ComponentCallToAction>
  189.      */
  190.     public function getComponentCallToActions(): Collection
  191.     {
  192.         return $this->componentCallToActions;
  193.     }
  194.     public function addComponentCallToAction(ComponentCallToAction $componentCallToAction): self
  195.     {
  196.         if (!$this->componentCallToActions->contains($componentCallToAction)) {
  197.             $this->componentCallToActions[] = $componentCallToAction;
  198.             $componentCallToAction->setCallToAction($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeComponentCallToAction(ComponentCallToAction $componentCallToAction): self
  203.     {
  204.         if ($this->componentCallToActions->removeElement($componentCallToAction)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($componentCallToAction->getCallToAction() === $this) {
  207.                 $componentCallToAction->setCallToAction(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, ProductCallToAction>
  214.      */
  215.     public function getProductCallToActions(): Collection
  216.     {
  217.         return $this->productCallToActions;
  218.     }
  219.     public function addProductCallToAction(ProductCallToAction $productCallToAction): self
  220.     {
  221.         if (!$this->productCallToActions->contains($productCallToAction)) {
  222.             $this->productCallToActions[] = $productCallToAction;
  223.             $productCallToAction->setCallToAction($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeProductCallToAction(ProductCallToAction $productCallToAction): self
  228.     {
  229.         if ($this->productCallToActions->removeElement($productCallToAction)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($productCallToAction->getCallToAction() === $this) {
  232.                 $productCallToAction->setCallToAction(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection<int, ComponentConfigurationCallToAction>
  239.      */
  240.     public function getComponentConfigurationCallToActions(): Collection
  241.     {
  242.         return $this->componentConfigurationCallToActions;
  243.     }
  244.     public function addComponentConfigurationCallToAction(ComponentConfigurationCallToAction $componentConfigurationCallToAction): self
  245.     {
  246.         if (!$this->componentConfigurationCallToActions->contains($componentConfigurationCallToAction)) {
  247.             $this->componentConfigurationCallToActions[] = $componentConfigurationCallToAction;
  248.             $componentConfigurationCallToAction->setCallToAction($this);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removeComponentConfigurationCallToAction(ComponentConfigurationCallToAction $componentConfigurationCallToAction): self
  253.     {
  254.         if ($this->componentConfigurationCallToActions->removeElement($componentConfigurationCallToAction)) {
  255.             // set the owning side to null (unless already changed)
  256.             if ($componentConfigurationCallToAction->getCallToAction() === $this) {
  257.                 $componentConfigurationCallToAction->setCallToAction(null);
  258.             }
  259.         }
  260.         return $this;
  261.     }
  262.     /**
  263.      * @return Collection<int, AboutConfigurationCallToAction>
  264.      */
  265.     public function getAboutConfigurationCallToActions(): Collection
  266.     {
  267.         return $this->aboutConfigurationCallToActions;
  268.     }
  269.     public function addAboutConfigurationCallToAction(AboutConfigurationCallToAction $aboutConfigurationCallToAction): self
  270.     {
  271.         if (!$this->aboutConfigurationCallToActions->contains($aboutConfigurationCallToAction)) {
  272.             $this->aboutConfigurationCallToActions[] = $aboutConfigurationCallToAction;
  273.             $aboutConfigurationCallToAction->setCallToAction($this);
  274.         }
  275.         return $this;
  276.     }
  277.     public function removeAboutConfigurationCallToAction(AboutConfigurationCallToAction $aboutConfigurationCallToAction): self
  278.     {
  279.         if ($this->aboutConfigurationCallToActions->removeElement($aboutConfigurationCallToAction)) {
  280.             // set the owning side to null (unless already changed)
  281.             if ($aboutConfigurationCallToAction->getCallToAction() === $this) {
  282.                 $aboutConfigurationCallToAction->setCallToAction(null);
  283.             }
  284.         }
  285.         return $this;
  286.     }
  287.     public function __toString(): string
  288.     {
  289.         return $this->getTitle();
  290.     }
  291. }