<?php
namespace App\Entity\Scholar\Module;
use App\Entity\Channel\Image;
use App\Entity\Channel\LockByInterface;
use App\Entity\Scholar\SharedScholarTrait;
use App\Repository\Scholar\SharedModuleRepository;
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_modules')]
#[ORM\Entity(repositoryClass: SharedModuleRepository::class)]
#[UniqueEntity(
fields: ['lockBy', 'ownerChannel'],
)]
class SharedModule extends Module implements LockByInterface
{
use SharedScholarTrait;
#[ORM\ManyToOne(targetEntity: OriginModule::class, fetch: 'EAGER', inversedBy: 'sharedModules')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?OriginModule $lockBy = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $lockByStatus = null;
public function getLockBy(): ?OriginModule
{
return $this->lockBy;
}
public function setLockBy(?OriginModule $lockBy): static
{
$this->lockBy = $lockBy;
return $this;
}
public function getImage(): ?Image
{
return $this->getLockBy()?->getImage();
}
public function getLockByStatus(): ?bool
{
return $this->lockByStatus;
}
public function setLockByStatus(?bool $status): static
{
$this->lockByStatus = $status;
return $this;
}
public function getLockByOwnerChannel(): ?ChannelInterface
{
return $this->getLockBy()?->getOwnerChannel();
}
}