File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/Resources/skeleton/security Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 8
8
9
9
class <?= $ class_name ?> extends Voter
10
10
{
11
+ public const EDIT = 'POST_EDIT';
12
+ public const VIEW = 'POST_VIEW';
13
+
11
14
protected function supports(<?= $ use_type_hints ? 'string ' : null ?> $attribute, $subject): bool
12
15
{
13
16
// replace with your own logic
14
17
// https://symfony.com/doc/current/security/voters.html
15
- return in_array($attribute, ['POST_EDIT', 'POST_VIEW' ])
18
+ return in_array($attribute, [self::EDIT, self::VIEW ])
16
19
&& $subject instanceof \App\Entity\<?= str_replace ('Voter ' , null , $ class_name ) ?> ;
17
20
}
18
21
@@ -26,11 +29,11 @@ protected function voteOnAttribute(<?= $use_type_hints ? 'string ' : null ?>$att
26
29
27
30
// ... (check conditions and return true to grant permission) ...
28
31
switch ($attribute) {
29
- case 'POST_EDIT' :
32
+ case self::EDIT :
30
33
// logic to determine if the user can EDIT
31
34
// return true or false
32
35
break;
33
- case 'POST_VIEW' :
36
+ case self::VIEW :
34
37
// logic to determine if the user can VIEW
35
38
// return true or false
36
39
break;
You can’t perform that action at this time.
0 commit comments