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

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. #[ORM\Table(name: 'scholar_shared_lessons')]
  12. #[ORM\Entity(repositoryClass: SharedLessonRepository::class)]
  13. #[UniqueEntity(
  14. fields: ['lockBy', 'ownerChannel'],
  15. )]
  16. class SharedLesson extends Lesson implements LockByInterface
  17. {
  18. use SharedScholarTrait;
  19. #[ORM\ManyToOne(targetEntity: OriginLesson::class, fetch: 'EAGER', inversedBy: 'sharedLessons')]
  20. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  21. private ?OriginLesson $lockBy = null;
  22. #[ORM\Column(type: 'integer', nullable: true)]
  23. private ?int $lockByStatus = null;
  24. public function isIndexed(): bool
  25. {
  26. return $this->getLockBy()?->isIndexed();
  27. }
  28. public function getIndexedContent(): ?IndexedContent
  29. {
  30. return $this->getLockBy()?->getIndexedContent();
  31. }
  32. public function getStatus(): ?string
  33. {
  34. return parent::getStatus();
  35. }
  36. public function getLockBy(): ?OriginLesson
  37. {
  38. return $this->lockBy;
  39. }
  40. public function setLockBy(?Lesson $lockBy): static
  41. {
  42. $this->lockBy = $lockBy;
  43. return $this;
  44. }
  45. public function getRef(): ?string
  46. {
  47. return $this->getLockBy()?->getRef();
  48. }
  49. public function getImage(): ?Image
  50. {
  51. return $this->getLockBy()?->getImage();
  52. }
  53. public function getObjective(): ?string
  54. {
  55. return $this->getLockBy()?->getObjective();
  56. }
  57. public function hasCaseStudy(): bool
  58. {
  59. return $this->getLockBy()?->hasCaseStudy();
  60. }
  61. public function getLockByStatus(): ?bool
  62. {
  63. return $this->lockByStatus;
  64. }
  65. public function setLockByStatus(?bool $status): static
  66. {
  67. $this->lockByStatus = $status;
  68. return $this;
  69. }
  70. public function getLockByOwnerChannel(): ?ChannelInterface
  71. {
  72. return $this->getLockBy()?->getOwnerChannel();
  73. }
  74. }