<?php
namespace App\Entity\Scholar\Chapter;
use App\Entity\Scholar\Indexed\IndexedContent;
use App\Entity\Scholar\LinksDTOTrait;
use App\Repository\Scholar\OriginChapterRepository;
use App\Validator\Constraints as AcmeAssert;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'scholar_origin_chapters')]
#[ORM\Entity(repositoryClass: OriginChapterRepository::class)]
class OriginChapter extends Chapter
{
use LinksDTOTrait;
#[ORM\Column(type: 'string', length: 255)]
#[
Assert\NotBlank(message: 'scholar.chapter.name.NotBlank'),
Assert\Length(
min: 2,
max: 255,
minMessage: 'scholar.chapter.name.Length.min',
maxMessage: 'scholar.chapter.name.Length.max',
),
AcmeAssert\HtmlTagConstraint
]
private ?string $name = null;
#[ORM\Column(type: 'text')]
#[
Assert\NotBlank(message: 'scholar.chapter.body.NotBlank'),
AcmeAssert\HtmlTagConstraint(),
]
private ?string $body = null;
#[ORM\Column(name: 'sort_order', type: 'integer')]
private ?int $order = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description;
#[ORM\OneToMany(mappedBy: 'lockBy', targetEntity: SharedChapter::class, cascade: ['remove'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
private ?Collection $sharedChapters;
#[ORM\OneToOne(targetEntity: IndexedContent::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
private ?IndexedContent $indexedContent;
public function isIndexed(): bool
{
return $this->getIndexedContent()?->getUuid() !== null;
}
public function getIndexedContent(): ?IndexedContent
{
return $this->indexedContent;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getBody(): ?string
{
return $this->body;
}
public function setBody(?string $body): static
{
$this->body = $body;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getOrder(): ?int
{
return $this->order;
}
public function setOrder(?int $order): static
{
$this->order = $order;
return $this;
}
public function getSharedChapters(): ?Collection
{
return $this->sharedChapters;
}
public function setSharedChapters(?Collection $sharedChapters): OriginChapter
{
$this->sharedChapters = $sharedChapters;
return $this;
}
public function setIndexedContent(?IndexedContent $indexedContent): OriginChapter
{
$this->indexedContent = $indexedContent;
return $this;
}
}