src/Entity/Service.php line 28

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\ORM\Mapping as ORM;
  6. use App\Entity\Traits\ActiveTrait;
  7. use App\Entity\Traits\DeleteTrait;
  8. use App\Entity\Traits\SubTitleTrait;
  9. use App\Entity\Traits\SortOrderTrait;
  10. use App\Entity\Traits\TranslateTrait;
  11. use App\Repository\ServiceRepository;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. use App\Entity\Traits\ImageUploadTrait;
  14. use App\Entity\Traits\SitemapableTrait;
  15. use App\Entity\Traits\TitleAndContentTrait;
  16. use App\Entity\Interfaces\DefaultLinkedEntity;
  17. use Gedmo\Timestampable\Traits\TimestampableEntity;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. /**
  20. * @Gedmo\Loggable
  21. */
  22. #[ORM\Entity(repositoryClass: \App\Repository\ServiceRepository::class)]
  23. #[ORM\HasLifecycleCallbacks]
  24. #[ORM\Table(name: 'service')]
  25. class Service implements DefaultLinkedEntity
  26. {
  27. use TitleAndContentTrait;
  28. use SubTitleTrait;
  29. use ImageUploadTrait;
  30. use SortOrderTrait;
  31. use ActiveTrait;
  32. use LinkTrait;
  33. use MetaTrait;
  34. use DeleteTrait;
  35. use TimestampableEntity;
  36. use TranslateTrait;
  37. use SitemapableTrait;
  38. #[ORM\Column(name: 'id', type: 'integer')]
  39. #[ORM\Id]
  40. #[ORM\GeneratedValue(strategy: 'AUTO')]
  41. private readonly int $id;
  42. #[ORM\Column(name: 'content2', type: 'text', nullable: true)]
  43. private ?string $content2 = null;
  44. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  45. private $cta_text;
  46. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  47. private $cta_link;
  48. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  49. private $cta_text2;
  50. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  51. private $cta_link2;
  52. #[ORM\ManyToOne(targetEntity: Testimonial::class)]
  53. private $testimonial;
  54. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  55. private $icon;
  56. #[ORM\Column(type: 'string', length: 255)]
  57. private $employer_or_employee;
  58. #[ORM\ManyToOne(targetEntity: ServiceCategory::class, inversedBy: 'services')]
  59. #[ORM\JoinColumn(nullable: false)]
  60. private $category;
  61. #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => true])]
  62. private bool $show_on_menu = true;
  63. /**
  64. * Override slug from LinkTrait to disable auto-update.
  65. * Slug will only be auto-generated on create, but can be manually set.
  66. *
  67. * @Gedmo\Translatable
  68. *
  69. * @Gedmo\Versioned
  70. *
  71. * @Gedmo\Slug(fields={"title"}, separator="-", updatable=false)
  72. */
  73. #[ORM\Column(length: 255, unique: true)]
  74. private ?string $slug = null;
  75. public function getId(): ?int
  76. {
  77. return $this->id;
  78. }
  79. // Required By The MetaTrait / DefaultLinkedEntity Interface
  80. public function getLinkedPageId(): int
  81. {
  82. return 14;
  83. }
  84. public function getContent2(): ?string
  85. {
  86. return $this->content2;
  87. }
  88. public function setContent2(?string $content2): self
  89. {
  90. $this->content2 = $content2;
  91. return $this;
  92. }
  93. public function getCtaText(): ?string
  94. {
  95. return $this->cta_text;
  96. }
  97. public function setCtaText(?string $cta_text): self
  98. {
  99. $this->cta_text = $cta_text;
  100. return $this;
  101. }
  102. public function getCtaLink(): ?string
  103. {
  104. return $this->cta_link;
  105. }
  106. public function setCtaLink(?string $cta_link): self
  107. {
  108. $this->cta_link = $cta_link;
  109. return $this;
  110. }
  111. public function getCtaText2(): ?string
  112. {
  113. return $this->cta_text2;
  114. }
  115. public function setCtaText2(?string $cta_text2): self
  116. {
  117. $this->cta_text2 = $cta_text2;
  118. return $this;
  119. }
  120. public function getCtaLink2(): ?string
  121. {
  122. return $this->cta_link2;
  123. }
  124. public function setCtaLink2(?string $cta_link2): self
  125. {
  126. $this->cta_link2 = $cta_link2;
  127. return $this;
  128. }
  129. public function getTestimonial(): ?Testimonial
  130. {
  131. return $this->testimonial;
  132. }
  133. public function setTestimonial(?Testimonial $testimonial): self
  134. {
  135. $this->testimonial = $testimonial;
  136. return $this;
  137. }
  138. public function getIcon(): ?string
  139. {
  140. return $this->icon;
  141. }
  142. public function setIcon(?string $icon): self
  143. {
  144. $this->icon = $icon;
  145. return $this;
  146. }
  147. public function getEmployerOrEmployee(): ?string
  148. {
  149. return $this->employer_or_employee;
  150. }
  151. public function setEmployerOrEmployee(string $employer_or_employee): self
  152. {
  153. $this->employer_or_employee = $employer_or_employee;
  154. return $this;
  155. }
  156. public function getCategory(): ?ServiceCategory
  157. {
  158. return $this->category;
  159. }
  160. public function setCategory(?ServiceCategory $category): self
  161. {
  162. $this->category = $category;
  163. return $this;
  164. }
  165. public function getShowOnMenu(): ?bool
  166. {
  167. return $this->show_on_menu;
  168. }
  169. public function setShowOnMenu(bool $show_on_menu): self
  170. {
  171. $this->show_on_menu = $show_on_menu;
  172. return $this;
  173. }
  174. public function getSitemapRouteParams(): array
  175. {
  176. return ['slug' => $this->getSlug()];
  177. }
  178. public function isIncludedInSitemap(): bool
  179. {
  180. return $this->isActive() &&
  181. ! $this->isDeleted();
  182. }
  183. /**
  184. * Override setSlug from LinkTrait to allow manual setting.
  185. * If empty string is provided, set to null to allow auto-generation on create.
  186. */
  187. public function setSlug(?string $slug): void
  188. {
  189. // Convert empty string to null so Gedmo can auto-generate on create
  190. $this->slug = ($slug === '' || $slug === null) ? null : $slug;
  191. }
  192. }