<?php
namespace App\Entity\Core;
use App\Entity\Core\Topic\Topic;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Table('template_set')]
#[ORM\Entity(repositoryClass: TemplateSetRepository::class)]
class TemplateSet implements JsonSerializable
{
/**
* @var int
*/
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\JoinColumn(name: 'topic_id', nullable: false)]
#[ORM\ManyToOne(targetEntity: Topic::class, inversedBy: 'templates')]
private Topic $topic;
#[ORM\Column(type: 'string', length: 255)]
private string $title;
#[ORM\Column(type: 'string', length: 1000, nullable: true)]
private ?string $description;
#[ORM\Column(name: 'recommended_duration', type: 'integer', nullable: true)]
private ?int $recommendedDuration;
#[ORM\Column(type: 'boolean', options: ['default' => true])]
private bool $enabled = true;
/**
* @var ArrayCollection|TemplateMathproblem[]
*/
#[ORM\JoinTable(name: 'relation_template_template_set')]
#[ORM\JoinColumn(name: 'template_set_id')]
#[ORM\InverseJoinColumn(name: 'template_id')]
#[ORM\ManyToMany(targetEntity: TemplateMathproblem::class, inversedBy: 'templateSets')]
private Collection $templates;
/**
* @var int
*/
#[ORM\Column(name: 'sort_order', type: 'integer', nullable: true, options: ['default' => 0])]
private $sortOrder;
public function __construct()
{
$this->templates = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function getTopic(): Topic
{
return $this->topic;
}
public function setTopic(Topic $topic): void
{
$this->topic = $topic;
}
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): void
{
$this->title = $title;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): void
{
$this->description = $description;
}
public function isEnabled(): bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): void
{
$this->enabled = $enabled;
}
/**
* @return TemplateMathproblem[]|ArrayCollection
*/
public function getTemplates(): Collection
{
return $this->templates;
}
public function addTemplate(TemplateMathproblem $template): void
{
if (!$this->templates->contains($template)) {
$this->templates->add($template);
$template->addTemplateSet($this);
}
}
/**
* @param TemplateMathproblem[]|ArrayCollection $templates
*/
public function setTemplates($templates): void
{
$this->templates = $templates;
}
public function getRecommendedDuration(): ?int
{
return $this->recommendedDuration;
}
public function setRecommendedDuration(?int $recommendedDuration): void
{
$this->recommendedDuration = $recommendedDuration;
}
public function jsonSerialize(): mixed
{
return [
"id" => $this->id,
"title" => $this->title,
"description" => $this->description,
];
}
/**
* @return int
*/
public function getSortOrder()
{
return $this->sortOrder;
}
/**
* @param int $sortOrder
*/
public function setSortOrder($sortOrder)
{
$this->sortOrder = $sortOrder;
}
}