src/Entity/CaseStudies.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\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\TranslateTrait;
  10. use App\Entity\Traits\FileUploadTrait;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use App\Entity\Traits\ImageUploadTrait;
  13. use App\Entity\Traits\SitemapableTrait;
  14. use App\Entity\Traits\TitleAndContentTrait;
  15. use App\Entity\Interfaces\DefaultLinkedEntity;
  16. use Gedmo\Timestampable\Traits\TimestampableEntity;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. /**
  19. * CaseStudies.
  20. *
  21. * @Gedmo\Loggable
  22. *
  23. * @Gedmo\TranslationEntity(class="App\Entity\CaseStudiesTranslations")
  24. */
  25. #[ORM\Entity(repositoryClass: \App\Repository\CaseStudiesRepository::class)]
  26. #[ORM\Table(name: 'casestudies')]
  27. class CaseStudies implements DefaultLinkedEntity
  28. {
  29. use TitleAndContentTrait;
  30. use SubTitleTrait;
  31. use LinkTrait;
  32. use MetaTrait;
  33. use ActiveTrait;
  34. use DeleteTrait;
  35. use ImageUploadTrait;
  36. use FileUploadTrait;
  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(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 $quote;
  50. #[ORM\ManyToOne(targetEntity: Testimonial::class)]
  51. private $testimonial;
  52. #[ORM\Column(type: 'boolean', nullable: true)]
  53. private $featured;
  54. #[ORM\Column(name: 'logo', type: 'string', length: 255, nullable: true)]
  55. private ?string $logo = null;
  56. /**
  57. * Override slug from LinkTrait to disable auto-update.
  58. * Slug will only be auto-generated on create, but can be manually set.
  59. *
  60. * @Gedmo\Translatable
  61. *
  62. * @Gedmo\Versioned
  63. *
  64. * @Gedmo\Slug(fields={"title"}, separator="-", updatable=false)
  65. */
  66. #[ORM\Column(length: 255, unique: true)]
  67. private ?string $slug = null;
  68. public function getId(): int
  69. {
  70. return $this->id;
  71. }
  72. // REQUIRED BY THE META LINKS TRAIT
  73. public function getLinkedPageId(): int
  74. {
  75. return 9;
  76. }
  77. public function getCtaText(): ?string
  78. {
  79. return $this->cta_text;
  80. }
  81. public function setCtaText(?string $cta_text): self
  82. {
  83. $this->cta_text = $cta_text;
  84. return $this;
  85. }
  86. public function getCtaLink(): ?string
  87. {
  88. return $this->cta_link;
  89. }
  90. public function setCtaLink(?string $cta_link): self
  91. {
  92. $this->cta_link = $cta_link;
  93. return $this;
  94. }
  95. public function getQuote(): ?string
  96. {
  97. return $this->quote;
  98. }
  99. public function setQuote(?string $quote): self
  100. {
  101. $this->quote = $quote;
  102. return $this;
  103. }
  104. public function getTestimonial(): ?Testimonial
  105. {
  106. return $this->testimonial;
  107. }
  108. public function setTestimonial(?Testimonial $testimonial): self
  109. {
  110. $this->testimonial = $testimonial;
  111. return $this;
  112. }
  113. public function getFeatured(): ?bool
  114. {
  115. return $this->featured;
  116. }
  117. public function setFeatured(?bool $featured): self
  118. {
  119. $this->featured = $featured;
  120. return $this;
  121. }
  122. public function getLogo(): ?string
  123. {
  124. return $this->logo;
  125. }
  126. public function setLogo(?string $logo): self
  127. {
  128. $this->logo = $logo;
  129. return $this;
  130. }
  131. public function getSitemapRouteParams(): array
  132. {
  133. return ['slug' => $this->getSlug()];
  134. }
  135. public function isIncludedInSitemap(): bool
  136. {
  137. return $this->isActive() &&
  138. ! $this->isDeleted();
  139. ;
  140. }
  141. /**
  142. * Override setSlug from LinkTrait to allow manual setting.
  143. * If empty string is provided, set to null to allow auto-generation on create.
  144. */
  145. public function setSlug(?string $slug): void
  146. {
  147. // Convert empty string to null so Gedmo can auto-generate on create
  148. $this->slug = ($slug === '' || $slug === null) ? null : $slug;
  149. }
  150. }