src/Entity/TeamMember.php line 29

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\SortOrderTrait;
  9. use App\Entity\Traits\TranslateTrait;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use App\Entity\Traits\ImageUploadTrait;
  12. use App\Entity\Traits\SitemapableTrait;
  13. use App\Entity\Traits\TitleAndContentTrait;
  14. use App\Entity\Interfaces\DefaultLinkedEntity;
  15. use Gedmo\Timestampable\Traits\TimestampableEntity;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. /**
  18. * MeetTheTeam.
  19. *
  20. * @Gedmo\Loggable
  21. *
  22. * @Gedmo\TranslationEntity(class="App\Entity\TeamMemberTranslations")
  23. */
  24. #[ORM\Entity(repositoryClass: \App\Repository\MeetTheTeamRepository::class)]
  25. #[ORM\Table(name: 'meettheteam')]
  26. class TeamMember implements DefaultLinkedEntity
  27. {
  28. use TitleAndContentTrait;
  29. use LinkTrait;
  30. use MetaTrait;
  31. use ActiveTrait;
  32. use DeleteTrait;
  33. use ImageUploadTrait;
  34. use TimestampableEntity;
  35. use TranslateTrait;
  36. use SortOrderTrait;
  37. use SitemapableTrait;
  38. #[ORM\Column(name: 'id', type: 'integer')]
  39. #[ORM\Id]
  40. #[ORM\GeneratedValue(strategy: 'AUTO')]
  41. private readonly int $id;
  42. /**
  43. * @Gedmo\Translatable
  44. */
  45. #[Assert\NotBlank(message: 'The position should not be blank')]
  46. #[ORM\Column(name: 'position', type: 'string', length: 255)]
  47. private ?string $position = null;
  48. #[Assert\Url(message: 'The LinkedIn URL is not valid')]
  49. #[ORM\Column(name: 'linkedin_url', type: 'string', length: 255, nullable: true)]
  50. private ?string $linkedinUrl = null;
  51. #[Assert\Email(message: 'The email address is not valid')]
  52. #[ORM\Column(name: 'email', type: 'string', length: 255, nullable: true)]
  53. private ?string $email = null;
  54. #[ORM\Column(name: 'post_nominal', type: 'string', length: 255, nullable: true)]
  55. private ?string $postNominal = null;
  56. #[ORM\Column(name: 'featured', type: 'boolean', nullable: true)]
  57. private ?bool $featured = false;
  58. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  59. private $cta_text;
  60. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  61. private $cta_link;
  62. #[ORM\ManyToOne(targetEntity: Testimonial::class)]
  63. #[ORM\JoinColumn(nullable: true)]
  64. private $testimonial;
  65. /**
  66. * Override slug from LinkTrait to disable auto-update.
  67. * Slug will only be auto-generated on create, but can be manually set.
  68. *
  69. * @Gedmo\Translatable
  70. *
  71. * @Gedmo\Versioned
  72. *
  73. * @Gedmo\Slug(fields={"title"}, separator="-", updatable=false)
  74. */
  75. #[ORM\Column(length: 255, unique: true)]
  76. private ?string $slug = null;
  77. /**
  78. * Get id.
  79. */
  80. public function getId(): int
  81. {
  82. return $this->id;
  83. }
  84. /**
  85. * Set position.
  86. *
  87. * @param string $position
  88. */
  89. public function setPosition($position): self
  90. {
  91. $this->position = $position;
  92. return $this;
  93. }
  94. /**
  95. * Get position.
  96. */
  97. public function getPosition(): ?string
  98. {
  99. return $this->position;
  100. }
  101. // REQUIRED BY THE LINKS TRAIT
  102. public function getLinkedPageId(): int
  103. {
  104. return 5;
  105. }
  106. public function getLinkedinUrl(): ?string
  107. {
  108. return $this->linkedinUrl;
  109. }
  110. public function setLinkedinUrl(?string $linkedinUrl): self
  111. {
  112. $this->linkedinUrl = $linkedinUrl;
  113. return $this;
  114. }
  115. public function getEmail(): ?string
  116. {
  117. return $this->email;
  118. }
  119. public function setEmail(?string $email): self
  120. {
  121. $this->email = $email;
  122. return $this;
  123. }
  124. public function getPostNominal(): ?string
  125. {
  126. return $this->postNominal;
  127. }
  128. public function setPostNominal(?string $postNominal): self
  129. {
  130. $this->postNominal = $postNominal;
  131. return $this;
  132. }
  133. public function getFeatured(): ?bool
  134. {
  135. return $this->featured;
  136. }
  137. public function setFeatured(?bool $featured): self
  138. {
  139. $this->featured = $featured;
  140. return $this;
  141. }
  142. public function getCtaText(): ?string
  143. {
  144. return $this->cta_text;
  145. }
  146. public function setCtaText(?string $cta_text): self
  147. {
  148. $this->cta_text = $cta_text;
  149. return $this;
  150. }
  151. public function getCtaLink(): ?string
  152. {
  153. return $this->cta_link;
  154. }
  155. public function setCtaLink(?string $cta_link): self
  156. {
  157. $this->cta_link = $cta_link;
  158. return $this;
  159. }
  160. public function getTestimonial(): ?Testimonial
  161. {
  162. return $this->testimonial;
  163. }
  164. public function setTestimonial(?Testimonial $testimonial): self
  165. {
  166. $this->testimonial = $testimonial;
  167. return $this;
  168. }
  169. public function getSitemapRouteParams(): array
  170. {
  171. return ['slug' => $this->getSlug()];
  172. }
  173. public function isIncludedInSitemap(): bool
  174. {
  175. return $this->isActive() &&
  176. ! $this->isDeleted();
  177. }
  178. /**
  179. * Override setSlug from LinkTrait to allow manual setting.
  180. * If empty string is provided, set to null to allow auto-generation on create.
  181. */
  182. public function setSlug(?string $slug): void
  183. {
  184. // Convert empty string to null so Gedmo can auto-generate on create
  185. $this->slug = ($slug === '' || $slug === null) ? null : $slug;
  186. }
  187. }