src/Entity/Scholar/Chapter/SharedChapter.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Scholar\Chapter;
  3. use App\Entity\Channel\LockByInterface;
  4. use App\Entity\Scholar\Indexed\IndexedContent;
  5. use App\Repository\Scholar\SharedChapterRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. #[ORM\Table(name: 'scholar_shared_chapters')]
  10. #[ORM\Entity(repositoryClass: SharedChapterRepository::class)]
  11. #[UniqueEntity(
  12. fields: ['lockBy', 'lesson'],
  13. )]
  14. class SharedChapter extends Chapter implements LockByInterface
  15. {
  16. #[ORM\ManyToOne(targetEntity: OriginChapter::class, fetch: 'EAGER', inversedBy: 'sharedChapters')]
  17. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  18. private ?OriginChapter $lockBy = null;
  19. public function isIndexed(): bool
  20. {
  21. return $this->getLockBy()?->isIndexed();
  22. }
  23. public function getIndexedContent(): ?IndexedContent
  24. {
  25. return $this->getLockBy()?->getIndexedContent();
  26. }
  27. public function getName(): ?string
  28. {
  29. return $this->lockBy?->getName();
  30. }
  31. public function getBody(): ?string
  32. {
  33. return $this->lockBy?->getBody();
  34. }
  35. public function getDescription(): ?string
  36. {
  37. return $this->lockBy?->getDescription();
  38. }
  39. public function getOrder(): ?int
  40. {
  41. return $this->lockBy?->getOrder();
  42. }
  43. public function getLockBy(): ?Chapter
  44. {
  45. return $this->lockBy;
  46. }
  47. public function setLockBy(?Chapter $lockBy): Chapter
  48. {
  49. $this->lockBy = $lockBy;
  50. return $this;
  51. }
  52. public function getLockByOwnerChannel(): ?ChannelInterface
  53. {
  54. return $this->getLockBy()?->getLesson()->getOwnerChannel();
  55. }
  56. public function getLockByStatus(): ?bool
  57. {
  58. return null;
  59. }
  60. public function setLockByStatus(?bool $status): static
  61. {
  62. return $this;
  63. }
  64. public function getOwnerChannel(): ?ChannelInterface
  65. {
  66. return $this->getLesson()->getOwnerChannel();
  67. }
  68. }