src/Entity/ServiceCategory.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\LinkTrait;
  4. use App\Entity\Traits\MetaTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\Entity\Traits\ActiveTrait;
  9. use App\Entity\Traits\DeleteTrait;
  10. use App\Entity\Traits\SubTitleTrait;
  11. use App\Entity\Traits\SortOrderTrait;
  12. use App\Entity\Traits\TranslateTrait;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use App\Entity\Traits\ImageUploadTrait;
  15. use App\Entity\Traits\SitemapableTrait;
  16. use App\Entity\Traits\TitleAndContentTrait;
  17. use App\Repository\ServiceCategoryRepository;
  18. use App\Entity\Interfaces\DefaultLinkedEntity;
  19. use Gedmo\Timestampable\Traits\TimestampableEntity;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. /**
  22. * @Gedmo\Loggable
  23. */
  24. #[ORM\Entity(repositoryClass: ServiceCategoryRepository::class)]
  25. #[ORM\HasLifecycleCallbacks]
  26. #[ORM\Table(name: 'service_category')]
  27. class ServiceCategory implements DefaultLinkedEntity
  28. {
  29. use TitleAndContentTrait;
  30. use SubTitleTrait;
  31. use ImageUploadTrait;
  32. use SortOrderTrait;
  33. use ActiveTrait;
  34. use LinkTrait;
  35. use MetaTrait;
  36. use DeleteTrait;
  37. use TimestampableEntity;
  38. use TranslateTrait;
  39. use SitemapableTrait;
  40. #[ORM\Column(name: 'id', type: 'integer')]
  41. #[ORM\Id]
  42. #[ORM\GeneratedValue(strategy: 'AUTO')]
  43. private readonly int $id;
  44. #[ORM\Column(name: 'content2', type: 'text', nullable: true)]
  45. private ?string $content2 = null;
  46. #[ORM\Column(name: 'content3', type: 'text', nullable: true)]
  47. private ?string $content3 = null;
  48. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  49. private $cta_text;
  50. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  51. private $cta_link;
  52. #[ORM\ManyToOne(targetEntity: Testimonial::class)]
  53. private $testimonial;
  54. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  55. private $icon;
  56. #[ORM\OneToMany(mappedBy: 'category', targetEntity: Service::class)]
  57. private $services;
  58. public function __construct()
  59. {
  60. $this->services = new ArrayCollection();
  61. }
  62. public function getId(): ?int
  63. {
  64. return $this->id;
  65. }
  66. // Required By The MetaTrait / DefaultLinkedEntity Interface
  67. public function getLinkedPageId(): int
  68. {
  69. // TODO - SET THIS CORRECTLY
  70. return 13;
  71. }
  72. public function getContent2(): ?string
  73. {
  74. return $this->content2;
  75. }
  76. public function setContent2(?string $content2): self
  77. {
  78. $this->content2 = $content2;
  79. return $this;
  80. }
  81. public function getContent3(): ?string
  82. {
  83. return $this->content3;
  84. }
  85. public function setContent3(?string $content3): self
  86. {
  87. $this->content3 = $content3;
  88. return $this;
  89. }
  90. public function getCtaText(): ?string
  91. {
  92. return $this->cta_text;
  93. }
  94. public function setCtaText(?string $cta_text): self
  95. {
  96. $this->cta_text = $cta_text;
  97. return $this;
  98. }
  99. public function getCtaLink(): ?string
  100. {
  101. return $this->cta_link;
  102. }
  103. public function setCtaLink(?string $cta_link): self
  104. {
  105. $this->cta_link = $cta_link;
  106. return $this;
  107. }
  108. public function getTestimonial(): ?Testimonial
  109. {
  110. return $this->testimonial;
  111. }
  112. public function setTestimonial(?Testimonial $testimonial): self
  113. {
  114. $this->testimonial = $testimonial;
  115. return $this;
  116. }
  117. public function getIcon(): ?string
  118. {
  119. return $this->icon;
  120. }
  121. public function setIcon(?string $icon): self
  122. {
  123. $this->icon = $icon;
  124. return $this;
  125. }
  126. /**
  127. * @return Collection<int, Service>
  128. */
  129. public function getServices(): Collection
  130. {
  131. return $this->services;
  132. }
  133. public function addService(Service $service): self
  134. {
  135. if (!$this->services->contains($service)) {
  136. $this->services[] = $service;
  137. $service->setCategory($this);
  138. }
  139. return $this;
  140. }
  141. public function removeService(Service $service): self
  142. {
  143. if ($this->services->removeElement($service)) {
  144. // set the owning side to null (unless already changed)
  145. if ($service->getCategory() === $this) {
  146. $service->setCategory(null);
  147. }
  148. }
  149. return $this;
  150. }
  151. public function getSitemapRouteParams(): array
  152. {
  153. return ['slug' => $this->getSlug()];
  154. }
  155. public function isIncludedInSitemap(): bool
  156. {
  157. return $this->isActive() &&
  158. ! $this->isDeleted();
  159. }
  160. }