<?php
namespace App\Entity\Exercise;
use App\Entity\Channel\LockByInterface;
use App\Repository\Scholar\SharedExerciseRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[ORM\Table(name: 'scholar_shared_exercises')]
#[ORM\Entity(repositoryClass: SharedExerciseRepository::class)]
#[UniqueEntity(
fields: ['lockBy', 'lesson'],
)]
class SharedExercise extends Exercise implements LockByInterface
{
#[ORM\ManyToOne(targetEntity: OriginExercise::class, fetch: 'EAGER', inversedBy: 'sharedExercises')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?OriginExercise $lockBy = null;
public function getName(): ?string
{
return $this->lockBy?->getName();
}
public function getDescription(): ?string
{
return $this->lockBy?->getDescription();
}
public function getQuestions(): Collection
{
return $this->lockBy?->getQuestions();
}
public function getLockBy(): ?Exercise
{
return $this->lockBy;
}
public function setLockBy(?Exercise $lockBy): Exercise
{
$this->lockBy = $lockBy;
return $this;
}
public function getLockByOwnerChannel(): ?ChannelInterface
{
return $this->getLockBy()?->getLesson()->getOwnerChannel();
}
public function getLockByStatus(): ?bool
{
return null;
}
public function getOrder(): ?int
{
return $this->lockBy?->getOrder();
}
public function setLockByStatus(?bool $status): static
{
return $this;
}
public function getOwnerChannel(): ?ChannelInterface
{
return $this->getLesson()->getOwnerChannel();
}
}