@@ -78,7 +78,7 @@ code like this:
78
78
{
79
79
#[Route('/posts/{id}', name: 'post_show')]
80
80
// check for "view" access: calls all voters
81
- #[IsGranted('show ', 'post')]
81
+ #[IsGranted('view ', 'post')]
82
82
public function show(Post $post): Response
83
83
{
84
84
// ...
@@ -98,14 +98,15 @@ code like this:
98
98
// src/Controller/PostController.php
99
99
100
100
// ...
101
+ use App\Security\PostVoter;
101
102
102
103
class PostController extends AbstractController
103
104
{
104
105
#[Route('/posts/{id}', name: 'post_show')]
105
106
public function show(Post $post): Response
106
107
{
107
108
// check for "view" access: calls all voters
108
- $this->denyAccessUnlessGranted('view' , $post);
109
+ $this->denyAccessUnlessGranted(PostVoter::VIEW , $post);
109
110
110
111
// ...
111
112
}
@@ -114,7 +115,7 @@ code like this:
114
115
public function edit(Post $post): Response
115
116
{
116
117
// check for "edit" access: calls all voters
117
- $this->denyAccessUnlessGranted('edit' , $post);
118
+ $this->denyAccessUnlessGranted(PostVoter::EDIT , $post);
118
119
119
120
// ...
120
121
}
0 commit comments