src/Entity/Scholar/Chapter/OriginChapter.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Scholar\Chapter;
  3. use App\Entity\Scholar\Indexed\IndexedContent;
  4. use App\Repository\Scholar\OriginChapterRepository;
  5. use App\Validator\Constraints as AcmeAssert;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\SerializedName;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Table(name: 'scholar_origin_chapters')]
  11. #[ORM\Entity(repositoryClass: OriginChapterRepository::class)]
  12. class OriginChapter extends Chapter
  13. {
  14. #[ORM\Column(type: 'string', length: 255)]
  15. #[
  16. Assert\NotBlank(message: 'scholar.chapter.name.NotBlank', groups: ['Default', 'api:scholar:write']),
  17. Assert\Length(
  18. min: 2,
  19. max: 255,
  20. minMessage: 'scholar.chapter.name.Length.min',
  21. maxMessage: 'scholar.chapter.name.Length.max',
  22. groups: ['Default', 'api:scholar:write'],
  23. ),
  24. AcmeAssert\HtmlTagConstraint(groups: ['Default', 'api:scholar:write'])
  25. ]
  26. private ?string $name = null;
  27. #[ORM\Column(type: 'text')]
  28. #[
  29. Assert\NotBlank(message: 'scholar.chapter.body.NotBlank', groups: ['Default', 'api:scholar:write']),
  30. AcmeAssert\HtmlTagConstraint(groups: ['Default', 'api:scholar:write']),
  31. ]
  32. private ?string $body = null;
  33. #[ORM\Column(name: 'sort_order', type: 'integer')]
  34. #[Assert\NotNull(groups: ['api:scholar:write'])]
  35. #[Assert\PositiveOrZero(groups: ['api:scholar:write'])]
  36. private ?int $order = null;
  37. #[ORM\Column(type: 'text', nullable: true)]
  38. private ?string $description = null;
  39. #[ORM\OneToMany(mappedBy: 'lockBy', targetEntity: SharedChapter::class, cascade: ['remove'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
  40. private ?Collection $sharedChapters;
  41. #[ORM\OneToOne(targetEntity: IndexedContent::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
  42. private ?IndexedContent $indexedContent;
  43. public function isIndexed(): bool
  44. {
  45. return $this->getIndexedContent()?->getUuid() !== null;
  46. }
  47. public function getIndexedContent(): ?IndexedContent
  48. {
  49. return $this->indexedContent;
  50. }
  51. public function getName(): ?string
  52. {
  53. return $this->name;
  54. }
  55. public function setName(?string $name): static
  56. {
  57. $this->name = $name;
  58. return $this;
  59. }
  60. public function getBody(): ?string
  61. {
  62. return $this->body;
  63. }
  64. public function setBody(?string $body): static
  65. {
  66. $this->body = $body;
  67. return $this;
  68. }
  69. public function getDescription(): ?string
  70. {
  71. return $this->description;
  72. }
  73. public function setDescription(?string $description): self
  74. {
  75. $this->description = $description;
  76. return $this;
  77. }
  78. #[SerializedName('order')]
  79. public function getOrder(): ?int
  80. {
  81. return $this->order;
  82. }
  83. public function setOrder(?int $order): static
  84. {
  85. $this->order = $order;
  86. return $this;
  87. }
  88. public function getSharedChapters(): ?Collection
  89. {
  90. return $this->sharedChapters;
  91. }
  92. public function setSharedChapters(?Collection $sharedChapters): OriginChapter
  93. {
  94. $this->sharedChapters = $sharedChapters;
  95. return $this;
  96. }
  97. public function setIndexedContent(?IndexedContent $indexedContent): OriginChapter
  98. {
  99. $this->indexedContent = $indexedContent;
  100. return $this;
  101. }
  102. }