src/CoreBundle/Entity/TemplateSet.php line 15

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JsonSerializable;
  7. /**
  8. * @ORM\Table("template_set")
  9. * @ORM\Entity(repositoryClass="TemplateSetRepository")
  10. */
  11. class TemplateSet implements JsonSerializable
  12. {
  13. /**
  14. * @var int
  15. *
  16. * @ORM\Column(name="id", type="integer")
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="AUTO")
  19. */
  20. private $id;
  21. /**
  22. * @ORM\ManyToOne(targetEntity="Topic", inversedBy="templates")
  23. * @ORM\JoinColumn(name="topic_id", nullable=false)
  24. */
  25. private Topic $topic;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. */
  29. private string $title;
  30. /**
  31. * @ORM\Column(type="string", length=1000, nullable=true)
  32. */
  33. private ?string $description;
  34. /**
  35. * @ORM\Column(name="recommended_duration", type="integer", nullable=true)
  36. */
  37. private ?int $recommendedDuration;
  38. /**
  39. * @ORM\Column(type="boolean", options={"default" : true})
  40. */
  41. private bool $enabled = true;
  42. /**
  43. * @var ArrayCollection|TemplateMathproblem[]
  44. *
  45. * @ORM\ManyToMany(targetEntity="TemplateMathproblem", inversedBy="templateSets")
  46. * @ORM\JoinTable(name="relation_template_template_set",
  47. * inverseJoinColumns={@ORM\JoinColumn(name="template_id")},
  48. * joinColumns={@ORM\JoinColumn(name="template_set_id")})
  49. */
  50. private Collection $templates;
  51. /**
  52. * @var int
  53. *
  54. * @ORM\Column(name="sort_order", type="integer", nullable=true, options={"default"=0})
  55. */
  56. private $sortOrder;
  57. public function __construct()
  58. {
  59. $this->templates = new ArrayCollection();
  60. }
  61. public function getId()
  62. {
  63. return $this->id;
  64. }
  65. public function getTopic(): Topic
  66. {
  67. return $this->topic;
  68. }
  69. public function setTopic(Topic $topic): void
  70. {
  71. $this->topic = $topic;
  72. }
  73. public function getTitle(): string
  74. {
  75. return $this->title;
  76. }
  77. public function setTitle(string $title): void
  78. {
  79. $this->title = $title;
  80. }
  81. public function getDescription(): ?string
  82. {
  83. return $this->description;
  84. }
  85. public function setDescription(string $description): void
  86. {
  87. $this->description = $description;
  88. }
  89. public function isEnabled(): bool
  90. {
  91. return $this->enabled;
  92. }
  93. public function setEnabled(bool $enabled): void
  94. {
  95. $this->enabled = $enabled;
  96. }
  97. /**
  98. * @return TemplateMathproblem[]|ArrayCollection
  99. */
  100. public function getTemplates(): Collection
  101. {
  102. return $this->templates;
  103. }
  104. public function addTemplate(TemplateMathproblem $template): void
  105. {
  106. if (!$this->templates->contains($template)) {
  107. $this->templates->add($template);
  108. $template->addTemplateSet($this);
  109. }
  110. }
  111. /**
  112. * @param TemplateMathproblem[]|ArrayCollection $templates
  113. */
  114. public function setTemplates($templates): void
  115. {
  116. $this->templates = $templates;
  117. }
  118. public function getRecommendedDuration(): ?int
  119. {
  120. return $this->recommendedDuration;
  121. }
  122. public function setRecommendedDuration(?int $recommendedDuration): void
  123. {
  124. $this->recommendedDuration = $recommendedDuration;
  125. }
  126. public function jsonSerialize(): mixed
  127. {
  128. return [
  129. "id" => $this->id,
  130. "title" => $this->title,
  131. "description" => $this->description,
  132. ];
  133. }
  134. /**
  135. * @return int
  136. */
  137. public function getSortOrder()
  138. {
  139. return $this->sortOrder;
  140. }
  141. /**
  142. * @param int $sortOrder
  143. */
  144. public function setSortOrder($sortOrder)
  145. {
  146. $this->sortOrder = $sortOrder;
  147. }
  148. }