Skip to content

Commit ca4962c

Browse files
committed
minor #283 [Voter] use ENTITY_ATTR instead of ATTR (lyrixx)
This PR was merged into the 1.0-dev branch. Discussion ---------- [Voter] use ENTITY_ATTR instead of ATTR This is a bit longer, but this is much more explicite. This is much easier to find all usage in a code base because the term is now unique Commits ------- 5405fc9 [Voter] use ENTITY_ATTR instead of ATTR
2 parents 15b24cf + 5405fc9 commit ca4962c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Resources/skeleton/security/Voter.tpl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected function supports($attribute, $subject)
1212
{
1313
// replace with your own logic
1414
// https://symfony.com/doc/current/security/voters.html
15-
return in_array($attribute, ['EDIT', 'VIEW'])
15+
return in_array($attribute, ['POST_EDIT', 'POST_VIEW'])
1616
&& $subject instanceof App\Entity\BlogPost;
1717
}
1818

@@ -26,11 +26,11 @@ protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
2626

2727
// ... (check conditions and return true to grant permission) ...
2828
switch ($attribute) {
29-
case 'EDIT':
29+
case 'POST_EDIT':
3030
// logic to determine if the user can EDIT
3131
// return true or false
3232
break;
33-
case 'VIEW':
33+
case 'POST_VIEW':
3434
// logic to determine if the user can VIEW
3535
// return true or false
3636
break;

0 commit comments

Comments
 (0)