26
26
use Symfony \Component \Uid \Uuid ;
27
27
use Symfony \Component \Validator \Constraints as Assert ;
28
28
29
- #[ApiResource(operations: [new Get (security: 'is_granted( \'VIEW \', object) ' ), new Put (security: 'is_granted( \'EDIT \', object) ' ), new Delete (security: 'is_granted( \'DELETE \', object) ' ), new GetCollection (security: 'is_granted( \'ROLE_USER \') ' ), new Post (securityPostDenormalize: 'is_granted( \'CREATE \', object) ' )], security: 'is_granted( \'ROLE_ADMIN \') or is_granted( \'ROLE_CURRENT_COURSE_TEACHER \') ' , denormalizationContext: ['groups ' => ['c_tool_intro:write ' ]], normalizationContext: ['groups ' => ['c_tool_intro:read ' ]])]
29
+ #[ApiResource(
30
+ operations: [
31
+ new Get (security: "is_granted('VIEW', object) " ),
32
+ new Put (security: "is_granted('EDIT', object) " ),
33
+ new Delete (security: "is_granted('DELETE', object) " ),
34
+ new GetCollection (security: "is_granted('ROLE_USER') " ),
35
+ new Post (securityPostDenormalize: "is_granted('CREATE', object) " ),
36
+ ],
37
+ normalizationContext: [
38
+ 'groups ' => ['c_tool_intro:read ' ],
39
+ ],
40
+ denormalizationContext: [
41
+ 'groups ' => ['c_tool_intro:write ' ],
42
+ ],
43
+ security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CURRENT_COURSE_TEACHER') " ,
44
+ )]
30
45
#[ORM \Table(name: 'c_tool_intro ' )]
31
46
#[ORM \Entity(repositoryClass: CToolIntroRepository::class)]
32
47
#[ApiFilter(filterClass: SearchFilter::class, properties: ['courseTool ' => 'exact ' ])]
@@ -39,51 +54,62 @@ class CToolIntro extends AbstractResource implements ResourceInterface, Resource
39
54
#[ORM \Id]
40
55
#[ORM \GeneratedValue]
41
56
protected ?int $ iid = null ;
57
+
42
58
#[Assert \NotNull]
43
59
#[Groups(['c_tool_intro:read ' , 'c_tool_intro:write ' ])]
44
60
#[ORM \Column(name: 'intro_text ' , type: 'text ' , nullable: false )]
45
61
protected string $ introText ;
62
+
46
63
#[Assert \NotNull]
47
64
#[Groups(['c_tool_intro:read ' , 'c_tool_intro:write ' ])]
48
65
#[ORM \ManyToOne(targetEntity: CTool::class)]
49
66
#[ORM \JoinColumn(name: 'c_tool_id ' , referencedColumnName: 'iid ' , nullable: false , onDelete: 'CASCADE ' )]
50
67
protected CTool $ courseTool ;
68
+
51
69
public function __toString (): string
52
70
{
53
71
return $ this ->getIntroText ();
54
72
}
73
+
55
74
public function getIid (): ?int
56
75
{
57
76
return $ this ->iid ;
58
77
}
78
+
59
79
public function getCourseTool (): CTool
60
80
{
61
81
return $ this ->courseTool ;
62
82
}
83
+
63
84
public function setCourseTool (CTool $ courseTool ): self
64
85
{
65
86
$ this ->courseTool = $ courseTool ;
66
87
67
88
return $ this ;
68
89
}
90
+
69
91
public function setIntroText (string $ introText ): self
70
92
{
71
93
$ this ->introText = $ introText ;
72
94
73
95
return $ this ;
74
96
}
97
+
75
98
public function getIntroText (): string
76
99
{
77
100
return $ this ->introText ;
78
101
}
102
+
79
103
public function getResourceIdentifier (): int |Uuid
80
104
{
81
105
return $ this ->getIid ();
82
106
}
107
+
83
108
public function getResourceName (): string
84
109
{
85
110
return $ this ->getCourseTool ()->getTitle ();
86
111
}
112
+
87
113
public function setResourceName (string $ name ): self
88
114
{
89
115
return $ this ;
0 commit comments