src/Entity/Exercise/SharedExercise.php line 17

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. #[ORM\Table(name'scholar_shared_exercises')]
  10. #[ORM\Entity(repositoryClassSharedExerciseRepository::class)]
  11. #[UniqueEntity(
  12.     fields: ['lockBy''lesson'],
  13. )]
  14. class SharedExercise extends Exercise implements LockByInterface
  15. {
  16.     #[ORM\ManyToOne(targetEntityOriginExercise::class, fetch'EAGER'inversedBy'sharedExercises')]
  17.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  18.     private ?OriginExercise $lockBy null;
  19.     public function getName(): ?string
  20.     {
  21.         return $this->lockBy?->getName();
  22.     }
  23.     public function getDescription(): ?string
  24.     {
  25.         return $this->lockBy?->getDescription();
  26.     }
  27.     public function getQuestions(): Collection
  28.     {
  29.         return $this->lockBy?->getQuestions();
  30.     }
  31.     public function getLockBy(): ?Exercise
  32.     {
  33.         return $this->lockBy;
  34.     }
  35.     public function setLockBy(?Exercise $lockBy): Exercise
  36.     {
  37.         $this->lockBy $lockBy;
  38.         return $this;
  39.     }
  40.     public function getLockByOwnerChannel(): ?ChannelInterface
  41.     {
  42.         return $this->getLockBy()?->getLesson()->getOwnerChannel();
  43.     }
  44.     public function getLockByStatus(): ?bool
  45.     {
  46.         return null;
  47.     }
  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. }