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 ApiPlatform\Core\Annotation\ApiResource; |
10
|
|
|
use Chamilo\CoreBundle\Entity\AbstractResource; |
11
|
|
|
use Chamilo\CoreBundle\Entity\ResourceInterface; |
12
|
|
|
use Chamilo\CoreBundle\Entity\ResourceShowCourseResourcesInSessionInterface; |
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
14
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
15
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @ORM\Table( |
19
|
|
|
* name="c_tool_intro", |
20
|
|
|
* indexes={ |
21
|
|
|
* } |
22
|
|
|
* ) |
23
|
|
|
* @ORM\Entity |
24
|
|
|
*/ |
25
|
|
|
#[ApiResource( |
26
|
|
|
attributes: [ |
27
|
|
|
'security' => "is_granted('ROLE_ADMIN') or is_granted('ROLE_CURRENT_COURSE_TEACHER')", |
28
|
|
|
], |
29
|
|
|
denormalizationContext: [ |
30
|
|
|
'groups' => ['c_tool_intro:write'], |
31
|
|
|
], |
32
|
|
|
normalizationContext: [ |
33
|
|
|
'groups' => ['c_tool_intro:read'], |
34
|
|
|
], |
35
|
|
|
)] |
36
|
|
|
class CToolIntro extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* @ORM\Column(name="iid", type="integer") |
40
|
|
|
* @ORM\Id |
41
|
|
|
* @ORM\GeneratedValue |
42
|
|
|
*/ |
43
|
|
|
protected int $iid; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ORM\Column(name="intro_text", type="text", nullable=false) |
47
|
|
|
*/ |
48
|
|
|
#[Assert\NotNull] |
49
|
|
|
#[Groups(['c_tool_intro:read', 'c_tool_intro:write'])] |
50
|
|
|
protected string $introText; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CTool") |
54
|
|
|
* @ORM\JoinColumn(name="c_tool_id", referencedColumnName="iid", nullable=false) |
55
|
|
|
*/ |
56
|
|
|
#[Assert\NotNull] |
57
|
|
|
#[Groups(['c_tool_intro:read', 'c_tool_intro:write'])] |
58
|
|
|
protected CTool $courseTool; |
59
|
|
|
|
60
|
|
|
public function __toString(): string |
61
|
|
|
{ |
62
|
|
|
return $this->getIntroText(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getIid(): int |
66
|
|
|
{ |
67
|
|
|
return $this->iid; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getCourseTool(): CTool |
71
|
|
|
{ |
72
|
|
|
return $this->courseTool; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setCourseTool(CTool $courseTool): self |
76
|
|
|
{ |
77
|
|
|
$this->courseTool = $courseTool; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function setIntroText(string $introText): self |
83
|
|
|
{ |
84
|
|
|
$this->introText = $introText; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function getIntroText(): string |
90
|
|
|
{ |
91
|
|
|
return $this->introText; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getResourceIdentifier(): int |
95
|
|
|
{ |
96
|
|
|
return $this->getIid(); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function getResourceName(): string |
100
|
|
|
{ |
101
|
|
|
return $this->getIntroText(); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function setResourceName(string $name): self |
105
|
|
|
{ |
106
|
|
|
return $this->setIntroText($name); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|