<?php
namespace App\Entity\Scholar\Chapter;
use App\Entity\Channel\LockByInterface;
use App\Repository\Scholar\SharedChapterRepository;
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_chapters')]
#[ORM\Entity(repositoryClass: SharedChapterRepository::class)]
#[UniqueEntity(
fields: ['lockBy', 'lesson'],
)]
class SharedChapter extends Chapter implements LockByInterface
{
#[ORM\ManyToOne(targetEntity: OriginChapter::class, fetch: 'EAGER', inversedBy: 'sharedChapters')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?OriginChapter $lockBy = null;
public function getName(): ?string
{
return $this->lockBy?->getName();
}
public function getBody(): ?string
{
return $this->lockBy?->getBody();
}
public function getDescription(): ?string
{
return $this->lockBy?->getDescription();
}
public function getOrder(): ?int
{
return $this->lockBy?->getOrder();
}
public function getLockBy(): ?Chapter
{
return $this->lockBy;
}
public function setLockBy(?Chapter $lockBy): Chapter
{
$this->lockBy = $lockBy;
return $this;
}
public function getLockByOwnerChannel(): ?ChannelInterface
{
return $this->getLockBy()?->getLesson()->getOwnerChannel();
}
public function getLockByStatus(): ?bool
{
return null;
}
public function setLockByStatus(?bool $status): static
{
return $this;
}
public function getOwnerChannel(): ?ChannelInterface
{
return $this->getLesson()->getOwnerChannel();
}
}