File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 1414use App \Entity \Post ;
1515use App \Form \PostType ;
1616use App \Repository \PostRepository ;
17+ use App \Security \PostVoter ;
1718use App \Utils \Slugger ;
1819use Sensio \Bundle \FrameworkExtraBundle \Configuration \IsGranted ;
1920use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
@@ -119,7 +120,7 @@ public function show(Post $post): Response
119120 {
120121 // This security check can also be performed
121122 // using an annotation: @IsGranted("show", subject="post", message="Posts can only be shown to their authors.")
122- $ this ->denyAccessUnlessGranted (' show ' , $ post , 'Posts can only be shown to their authors. ' );
123+ $ this ->denyAccessUnlessGranted (PostVoter:: SHOW , $ post , 'Posts can only be shown to their authors. ' );
123124
124125 return $ this ->render ('admin/blog/show.html.twig ' , [
125126 'post ' => $ post ,
Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ class PostVoter extends Voter
2828{
2929 // Defining these constants is overkill for this simple application, but for real
3030 // applications, it's a recommended practice to avoid relying on "magic strings"
31- private const SHOW = 'show ' ;
32- private const EDIT = 'edit ' ;
33- private const DELETE = 'delete ' ;
31+ public const DELETE = 'delete ' ;
32+ public const EDIT = 'edit ' ;
33+ public const SHOW = 'show ' ;
3434
3535 /**
3636 * {@inheritdoc}
You can’t perform that action at this time.
0 commit comments