src/Entity/Scholar/Lesson/OriginLesson.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Scholar\Lesson;
  3. use App\Entity\Channel\Image;
  4. use App\Entity\Scholar\Indexed\IndexedContent;
  5. use App\Entity\Scholar\OriginScholarInterface;
  6. use App\Entity\Scholar\OriginScholarPropertyTrait;
  7. use App\Repository\Scholar\OriginLessonRepository;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. #[ORM\Table(name: 'scholar_origin_lessons')]
  13. #[ORM\Entity(repositoryClass: OriginLessonRepository::class)]
  14. class OriginLesson extends Lesson implements OriginScholarInterface
  15. {
  16. use OriginScholarPropertyTrait;
  17. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  18. #[
  19. Assert\Length(
  20. min: 2,
  21. max: 255,
  22. minMessage: 'scholar.ref.name.Length.min',
  23. maxMessage: 'scholar.ref.name.Length.max'
  24. )
  25. ]
  26. private ?string $ref = null;
  27. #[ORM\ManyToOne(targetEntity: Image::class)]
  28. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  29. private ?Image $image = null;
  30. #[ORM\Column(type: 'text', nullable: true)]
  31. private ?string $objective = null;
  32. #[ORM\OneToMany(mappedBy: 'lockBy', targetEntity: SharedLesson::class, cascade: ['remove'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
  33. private ?Collection $sharedLessons;
  34. #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => true])]
  35. private bool $lessonReviewActivated = true;
  36. #[ORM\OneToOne(targetEntity: IndexedContent::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
  37. private ?IndexedContent $indexedContent = null;
  38. public function isIndexed(): bool
  39. {
  40. return $this->getIndexedContent() !== null;
  41. }
  42. public function getIndexedContent(): ?IndexedContent
  43. {
  44. return $this->indexedContent;
  45. }
  46. public function setRef(?string $ref): Lesson
  47. {
  48. $this->ref = $ref;
  49. return $this;
  50. }
  51. public function setImage(?Image $image): static
  52. {
  53. $this->image = $image;
  54. return $this;
  55. }
  56. public function setObjective(?string $objective): self
  57. {
  58. $this->objective = $objective;
  59. return $this;
  60. }
  61. public function hasCaseStudy(): bool
  62. {
  63. return $this->getActivePracticalCase() !== null;
  64. }
  65. #[Groups(['Nellapp_Api'])]
  66. public function getRef(): ?string
  67. {
  68. return $this->ref;
  69. }
  70. public function getImage(): ?Image
  71. {
  72. return $this->image;
  73. }
  74. public function getObjective(): ?string
  75. {
  76. return $this->objective;
  77. }
  78. public function getSharedLessons(): ?Collection
  79. {
  80. return $this->sharedLessons;
  81. }
  82. public function setSharedLessons(?Collection $sharedLessons): OriginLesson
  83. {
  84. $this->sharedLessons = $sharedLessons;
  85. return $this;
  86. }
  87. public function setIndexedContent(?IndexedContent $indexedContent): OriginLesson
  88. {
  89. $this->indexedContent = $indexedContent;
  90. return $this;
  91. }
  92. }