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 14
14
use App \Entity \Post ;
15
15
use App \Form \PostType ;
16
16
use App \Repository \PostRepository ;
17
+ use App \Security \PostVoter ;
17
18
use App \Utils \Slugger ;
18
19
use Sensio \Bundle \FrameworkExtraBundle \Configuration \IsGranted ;
19
20
use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
@@ -119,7 +120,7 @@ public function show(Post $post): Response
119
120
{
120
121
// This security check can also be performed
121
122
// 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. ' );
123
124
124
125
return $ this ->render ('admin/blog/show.html.twig ' , [
125
126
'post ' => $ post ,
Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ class PostVoter extends Voter
28
28
{
29
29
// Defining these constants is overkill for this simple application, but for real
30
30
// 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 ' ;
34
34
35
35
/**
36
36
* {@inheritdoc}
You can’t perform that action at this time.
0 commit comments