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 88
99class <?= $ class_name ?> extends Voter
1010{
11+ const EDIT = 'POST_EDIT';
12+ const VIEW = 'POST_VIEW';
13+
1114 protected function supports(<?= $ use_type_hints ? 'string ' : null ?> $attribute, $subject): bool
1215 {
1316 // replace with your own logic
1417 // 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 ])
1619 && $subject instanceof \App\Entity\<?= str_replace ('Voter ' , null , $ class_name ) ?> ;
1720 }
1821
@@ -26,11 +29,11 @@ protected function voteOnAttribute(<?= $use_type_hints ? 'string ' : null ?>$att
2629
2730 // ... (check conditions and return true to grant permission) ...
2831 switch ($attribute) {
29- case 'POST_EDIT' :
32+ case self::EDIT :
3033 // logic to determine if the user can EDIT
3134 // return true or false
3235 break;
33- case 'POST_VIEW' :
36+ case self::VIEW :
3437 // logic to determine if the user can VIEW
3538 // return true or false
3639 break;
You can’t perform that action at this time.
0 commit comments