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\CoreBundle\Entity\ResourceShowCourseResourcesInSessionInterface; |
||
12 | use Chamilo\CourseBundle\Repository\CCourseDescriptionRepository; |
||
13 | use Doctrine\ORM\Mapping as ORM; |
||
14 | use Stringable; |
||
15 | use Symfony\Component\Uid\Uuid; |
||
16 | use Symfony\Component\Validator\Constraints as Assert; |
||
17 | |||
18 | #[ORM\Table(name: 'c_course_description')] |
||
19 | #[ORM\Entity(repositoryClass: CCourseDescriptionRepository::class)] |
||
20 | class CCourseDescription extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable |
||
21 | { |
||
22 | public const TYPE_DESCRIPTION = 1; |
||
23 | public const TYPE_OBJECTIVES = 2; |
||
24 | public const TYPE_TOPICS = 3; |
||
25 | public const TYPE_METHODOLOGY = 4; |
||
26 | public const TYPE_COURSE_MATERIAL = 5; |
||
27 | public const TYPE_RESOURCES = 6; |
||
28 | public const TYPE_ASSESSMENT = 7; |
||
29 | public const TYPE_CUSTOM = 8; |
||
30 | |||
31 | #[ORM\Column(name: 'iid', type: 'integer')] |
||
32 | #[ORM\Id] |
||
33 | #[ORM\GeneratedValue] |
||
34 | protected ?int $iid = null; |
||
35 | |||
36 | #[Assert\NotBlank] |
||
37 | #[ORM\Column(name: 'title', type: 'text', nullable: true)] |
||
38 | protected ?string $title = null; |
||
39 | |||
40 | #[ORM\Column(name: 'content', type: 'text', nullable: true)] |
||
41 | protected ?string $content; |
||
42 | |||
43 | #[Assert\Choice(callback: 'getTypes')] |
||
44 | #[ORM\Column(name: 'description_type', type: 'integer', nullable: false)] |
||
45 | protected int $descriptionType; |
||
46 | |||
47 | #[ORM\Column(name: 'progress', type: 'integer', nullable: false)] |
||
48 | protected int $progress; |
||
49 | |||
50 | public function __construct() |
||
51 | { |
||
52 | $this->content = ''; |
||
53 | $this->progress = 0; |
||
54 | $this->descriptionType = 1; |
||
55 | } |
||
56 | |||
57 | public function __toString(): string |
||
58 | { |
||
59 | return $this->getTitle(); |
||
60 | } |
||
61 | |||
62 | public static function getTypes(): array |
||
63 | { |
||
64 | return [ |
||
65 | self::TYPE_DESCRIPTION, |
||
66 | self::TYPE_OBJECTIVES, |
||
67 | self::TYPE_TOPICS, |
||
68 | self::TYPE_METHODOLOGY, |
||
69 | self::TYPE_COURSE_MATERIAL, |
||
70 | self::TYPE_RESOURCES, |
||
71 | self::TYPE_ASSESSMENT, |
||
72 | self::TYPE_CUSTOM, |
||
73 | ]; |
||
74 | } |
||
75 | |||
76 | public function setTitle(string $title): self |
||
77 | { |
||
78 | $this->title = $title; |
||
79 | |||
80 | return $this; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Get title. |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getTitle() |
||
89 | { |
||
90 | return $this->title; |
||
91 | } |
||
92 | |||
93 | public function setContent(string $content): self |
||
94 | { |
||
95 | $this->content = $content; |
||
96 | |||
97 | return $this; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Get content. |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getContent() |
||
106 | { |
||
107 | return $this->content; |
||
108 | } |
||
109 | |||
110 | public function setDescriptionType(int $descriptionType): self |
||
111 | { |
||
112 | $this->descriptionType = $descriptionType; |
||
113 | |||
114 | return $this; |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * Get descriptionType. |
||
119 | * |
||
120 | * @return int |
||
121 | */ |
||
122 | public function getDescriptionType() |
||
123 | { |
||
124 | return $this->descriptionType; |
||
125 | } |
||
126 | |||
127 | public function setProgress(int $progress): self |
||
128 | { |
||
129 | $this->progress = $progress; |
||
130 | |||
131 | return $this; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Get progress. |
||
136 | * |
||
137 | * @return int |
||
138 | */ |
||
139 | public function getProgress() |
||
140 | { |
||
141 | return $this->progress; |
||
142 | } |
||
143 | |||
144 | public function getIid(): ?int |
||
145 | { |
||
146 | return $this->iid; |
||
147 | } |
||
148 | |||
149 | public function getResourceIdentifier(): int|Uuid |
||
150 | { |
||
151 | return $this->getIid(); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
152 | } |
||
153 | |||
154 | public function getResourceName(): string |
||
155 | { |
||
156 | return $this->getTitle(); |
||
157 | } |
||
158 | |||
159 | public function setResourceName(string $name): self |
||
160 | { |
||
161 | return $this->setTitle($name); |
||
162 | } |
||
163 | } |
||
164 |