src/Entity/Scholar/Lesson/SharedLesson.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Scholar\Lesson;
  3. use App\Entity\Channel\Image;
  4. use App\Entity\Channel\LockByInterface;
  5. use App\Entity\Scholar\Indexed\IndexedContent;
  6. use App\Entity\Scholar\SharedScholarTrait;
  7. use App\Repository\Scholar\SharedLessonRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Table(name: 'scholar_shared_lessons')]
  13. #[ORM\Entity(repositoryClass: SharedLessonRepository::class)]
  14. #[UniqueEntity(
  15. fields: ['lockBy', 'ownerChannel'],
  16. )]
  17. class SharedLesson extends Lesson implements LockByInterface
  18. {
  19. use SharedScholarTrait;
  20. #[ORM\ManyToOne(targetEntity: OriginLesson::class, fetch: 'EAGER', inversedBy: 'sharedLessons')]
  21. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  22. private ?OriginLesson $lockBy = null;
  23. #[ORM\Column(type: 'integer', nullable: true)]
  24. private ?int $lockByStatus = null;
  25. public function isIndexed(): bool
  26. {
  27. return $this->getLockBy()?->isIndexed();
  28. }
  29. public function getIndexedContent(): ?IndexedContent
  30. {
  31. return $this->getLockBy()?->getIndexedContent();
  32. }
  33. public function getStatus(): ?string
  34. {
  35. return parent::getStatus();
  36. }
  37. public function getLockBy(): ?OriginLesson
  38. {
  39. return $this->lockBy;
  40. }
  41. public function setLockBy(?Lesson $lockBy): static
  42. {
  43. $this->lockBy = $lockBy;
  44. return $this;
  45. }
  46. #[Groups(['Nellapp_Api'])]
  47. public function getRef(): ?string
  48. {
  49. return $this->getLockBy()?->getRef();
  50. }
  51. public function getImage(): ?Image
  52. {
  53. return $this->getLockBy()?->getImage();
  54. }
  55. public function getObjective(): ?string
  56. {
  57. return $this->getLockBy()?->getObjective();
  58. }
  59. public function hasCaseStudy(): bool
  60. {
  61. return $this->getLockBy()?->hasCaseStudy();
  62. }
  63. public function getLockByStatus(): ?bool
  64. {
  65. return $this->lockByStatus;
  66. }
  67. public function setLockByStatus(?bool $status): static
  68. {
  69. $this->lockByStatus = $status;
  70. return $this;
  71. }
  72. public function getLockByOwnerChannel(): ?ChannelInterface
  73. {
  74. return $this->getLockBy()?->getOwnerChannel();
  75. }
  76. }