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

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. use Symfony\Component\Serializer\Annotation\SerializedName;
  10. #[ORM\Table(name: 'scholar_shared_chapters')]
  11. #[ORM\Entity(repositoryClass: SharedChapterRepository::class)]
  12. #[UniqueEntity(
  13. fields: ['lockBy', 'lesson'],
  14. )]
  15. class SharedChapter extends Chapter implements LockByInterface
  16. {
  17. #[ORM\ManyToOne(targetEntity: OriginChapter::class, fetch: 'EAGER', inversedBy: 'sharedChapters')]
  18. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  19. private ?OriginChapter $lockBy = null;
  20. public function isIndexed(): bool
  21. {
  22. return $this->getLockBy()?->isIndexed();
  23. }
  24. public function getIndexedContent(): ?IndexedContent
  25. {
  26. return $this->getLockBy()?->getIndexedContent();
  27. }
  28. public function getName(): ?string
  29. {
  30. return $this->lockBy?->getName();
  31. }
  32. public function getBody(): ?string
  33. {
  34. return $this->lockBy?->getBody();
  35. }
  36. public function getDescription(): ?string
  37. {
  38. return $this->lockBy?->getDescription();
  39. }
  40. #[SerializedName('order')]
  41. public function getOrder(): ?int
  42. {
  43. return $this->lockBy?->getOrder();
  44. }
  45. public function getLockBy(): ?Chapter
  46. {
  47. return $this->lockBy;
  48. }
  49. public function setLockBy(?Chapter $lockBy): Chapter
  50. {
  51. $this->lockBy = $lockBy;
  52. return $this;
  53. }
  54. public function getLockByOwnerChannel(): ?ChannelInterface
  55. {
  56. return $this->getLockBy()?->getLesson()->getOwnerChannel();
  57. }
  58. public function getLockByStatus(): ?bool
  59. {
  60. return null;
  61. }
  62. public function setLockByStatus(?bool $status): static
  63. {
  64. return $this;
  65. }
  66. public function getOwnerChannel(): ?ChannelInterface
  67. {
  68. return $this->getLesson()->getOwnerChannel();
  69. }
  70. }