<?php
namespace App\Entity\Scholar\Lesson;
use App\Entity\Channel\Image;
use App\Entity\Scholar\Indexed\IndexedContent;
use App\Entity\Scholar\OriginScholarInterface;
use App\Entity\Scholar\OriginScholarPropertyTrait;
use App\Repository\Scholar\OriginLessonRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serial;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'scholar_origin_lessons')]
#[ORM\Entity(repositoryClass: OriginLessonRepository::class)]
class OriginLesson extends Lesson implements OriginScholarInterface
{
use OriginScholarPropertyTrait;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[
Assert\Length(
min: 2,
max: 255,
minMessage: 'scholar.ref.name.Length.min',
maxMessage: 'scholar.ref.name.Length.max'
)
]
private ?string $ref = null;
#[ORM\ManyToOne(targetEntity: Image::class)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
#[Serial\Groups(['partner_api_lessons_show'])]
private ?Image $image = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $objective = null;
#[ORM\OneToMany(mappedBy: 'lockBy', targetEntity: SharedLesson::class, cascade: ['remove'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
private ?Collection $sharedLessons;
#[ORM\Column(type: 'boolean', nullable: false, options: ['default' => true])]
private bool $lessonReviewActivated = true;
#[ORM\OneToOne(targetEntity: IndexedContent::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
private ?IndexedContent $indexedContent = null;
public function isIndexed(): bool
{
return $this->getIndexedContent() !== null;
}
public function getIndexedContent(): ?IndexedContent
{
return $this->indexedContent;
}
public function setRef(?string $ref): Lesson
{
$this->ref = $ref;
return $this;
}
public function setImage(?Image $image): static
{
$this->image = $image;
return $this;
}
public function setObjective(?string $objective): self
{
$this->objective = $objective;
return $this;
}
public function hasCaseStudy(): bool
{
return $this->getActivePracticalCase() !== null;
}
public function getRef(): ?string
{
return $this->ref;
}
public function getImage(): ?Image
{
return $this->image;
}
public function getObjective(): ?string
{
return $this->objective;
}
public function getSharedLessons(): ?Collection
{
return $this->sharedLessons;
}
public function setSharedLessons(?Collection $sharedLessons): OriginLesson
{
$this->sharedLessons = $sharedLessons;
return $this;
}
public function setIndexedContent(?IndexedContent $indexedContent): OriginLesson
{
$this->indexedContent = $indexedContent;
return $this;
}
}