src/Entity/Exercise/SharedExercise.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Exercise;
  3. use App\Entity\Channel\LockByInterface;
  4. use App\Repository\Scholar\SharedExerciseRepository;
  5. use Doctrine\Common\Collections\Collection;
  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_exercises')]
  11. #[ORM\Entity(repositoryClass: SharedExerciseRepository::class)]
  12. #[UniqueEntity(fields: ['lockBy', 'lesson'])]
  13. class SharedExercise extends Exercise implements LockByInterface
  14. {
  15. #[ORM\ManyToOne(targetEntity: OriginExercise::class, fetch: 'EAGER', inversedBy: 'sharedExercises')]
  16. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  17. private ?OriginExercise $lockBy = null;
  18. public function getName(): ?string
  19. {
  20. return $this->lockBy?->getName();
  21. }
  22. public function getDescription(): ?string
  23. {
  24. return $this->lockBy?->getDescription();
  25. }
  26. public function getQuestions(): Collection
  27. {
  28. return $this->lockBy?->getQuestions();
  29. }
  30. public function getLockBy(): ?Exercise
  31. {
  32. return $this->lockBy;
  33. }
  34. public function setLockBy(?Exercise $lockBy): Exercise
  35. {
  36. $this->lockBy = $lockBy;
  37. return $this;
  38. }
  39. public function getLockByOwnerChannel(): ?ChannelInterface
  40. {
  41. return $this->getLockBy()?->getLesson()->getOwnerChannel();
  42. }
  43. public function getLockByStatus(): ?bool
  44. {
  45. return null;
  46. }
  47. #[SerializedName('order')]
  48. public function getOrder(): ?int
  49. {
  50. return $this->lockBy?->getOrder();
  51. }
  52. public function setLockByStatus(?bool $status): static
  53. {
  54. return $this;
  55. }
  56. public function getOwnerChannel(): ?ChannelInterface
  57. {
  58. return $this->getLesson()->getOwnerChannel();
  59. }
  60. }