1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* For licensing terms, see /license.txt */ |
||
6 | |||
7 | namespace Chamilo\CourseBundle\Entity; |
||
8 | |||
9 | use Chamilo\CoreBundle\Entity\AbstractResource; |
||
10 | use Chamilo\CoreBundle\Entity\ResourceInterface; |
||
11 | use Chamilo\CourseBundle\Repository\CThematicRepository; |
||
12 | use Doctrine\Common\Collections\ArrayCollection; |
||
13 | use Doctrine\Common\Collections\Collection; |
||
14 | use Doctrine\ORM\Mapping as ORM; |
||
15 | use Stringable; |
||
16 | use Symfony\Component\Uid\Uuid; |
||
17 | use Symfony\Component\Validator\Constraints as Assert; |
||
18 | |||
19 | #[ORM\Table(name: 'c_thematic')] |
||
20 | #[ORM\Index(columns: ['active'], name: 'active')] |
||
21 | #[ORM\Entity(repositoryClass: CThematicRepository::class)] |
||
22 | class CThematic extends AbstractResource implements ResourceInterface, Stringable |
||
23 | { |
||
24 | #[ORM\Column(name: 'iid', type: 'integer')] |
||
25 | #[ORM\Id] |
||
26 | #[ORM\GeneratedValue] |
||
27 | protected ?int $iid = null; |
||
28 | |||
29 | #[Assert\NotBlank] |
||
30 | #[ORM\Column(name: 'title', type: 'text', nullable: false)] |
||
31 | protected string $title; |
||
32 | |||
33 | #[ORM\Column(name: 'content', type: 'text', nullable: true)] |
||
34 | protected ?string $content = null; |
||
35 | |||
36 | #[ORM\Column(name: 'active', type: 'boolean', nullable: false)] |
||
37 | protected bool $active; |
||
38 | |||
39 | /** |
||
40 | * @var Collection<int, CThematicPlan> |
||
41 | */ |
||
42 | #[ORM\OneToMany(mappedBy: 'thematic', targetEntity: CThematicPlan::class, cascade: ['persist', 'remove'], orphanRemoval: true)] |
||
43 | protected Collection $plans; |
||
44 | |||
45 | /** |
||
46 | * @var Collection<int, CThematicAdvance> |
||
47 | */ |
||
48 | #[ORM\OrderBy(['startDate' => 'ASC'])] |
||
49 | #[ORM\OneToMany(mappedBy: 'thematic', targetEntity: CThematicAdvance::class, cascade: ['persist', 'remove'], orphanRemoval: true)] |
||
50 | protected Collection $advances; |
||
51 | |||
52 | public function __construct() |
||
53 | { |
||
54 | $this->plans = new ArrayCollection(); |
||
55 | $this->advances = new ArrayCollection(); |
||
56 | $this->active = true; |
||
57 | } |
||
58 | |||
59 | public function __toString(): string |
||
60 | { |
||
61 | return $this->getTitle(); |
||
62 | } |
||
63 | |||
64 | public function setTitle(string $title): self |
||
65 | { |
||
66 | $this->title = $title; |
||
67 | |||
68 | return $this; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Get title. |
||
73 | */ |
||
74 | public function getTitle(): string |
||
75 | { |
||
76 | return $this->title; |
||
77 | } |
||
78 | |||
79 | public function setContent(string $content): self |
||
80 | { |
||
81 | $this->content = $content; |
||
82 | |||
83 | return $this; |
||
84 | } |
||
85 | |||
86 | public function getContent(): ?string |
||
87 | { |
||
88 | return $this->content; |
||
89 | } |
||
90 | |||
91 | public function setActive(bool $active): self |
||
92 | { |
||
93 | $this->active = $active; |
||
94 | |||
95 | return $this; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Get active. |
||
100 | */ |
||
101 | public function getActive(): bool |
||
102 | { |
||
103 | return $this->active; |
||
104 | } |
||
105 | |||
106 | public function getIid(): ?int |
||
107 | { |
||
108 | return $this->iid; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @return Collection<int, CThematicPlan> |
||
113 | */ |
||
114 | public function getPlans(): Collection |
||
115 | { |
||
116 | return $this->plans; |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * @return Collection<int, CThematicAdvance> |
||
121 | */ |
||
122 | public function getAdvances(): Collection |
||
123 | { |
||
124 | return $this->advances; |
||
125 | } |
||
126 | |||
127 | public function getResourceIdentifier(): int|Uuid |
||
128 | { |
||
129 | return $this->getIid(); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
130 | } |
||
131 | |||
132 | public function getResourceName(): string |
||
133 | { |
||
134 | return $this->getTitle(); |
||
135 | } |
||
136 | |||
137 | public function setResourceName(string $name): self |
||
138 | { |
||
139 | return $this->setTitle($name); |
||
140 | } |
||
141 | } |
||
142 |