Skip to content

Commit 21e222c

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Update voters.rst
2 parents 3781d05 + c7578c6 commit 21e222c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

security/voters.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ code like this:
7878
{
7979
#[Route('/posts/{id}', name: 'post_show')]
8080
// check for "view" access: calls all voters
81-
#[IsGranted('show', 'post')]
81+
#[IsGranted('view', 'post')]
8282
public function show(Post $post): Response
8383
{
8484
// ...
@@ -98,14 +98,15 @@ code like this:
9898
// src/Controller/PostController.php
9999
100100
// ...
101+
use App\Security\PostVoter;
101102
102103
class PostController extends AbstractController
103104
{
104105
#[Route('/posts/{id}', name: 'post_show')]
105106
public function show(Post $post): Response
106107
{
107108
// check for "view" access: calls all voters
108-
$this->denyAccessUnlessGranted('view', $post);
109+
$this->denyAccessUnlessGranted(PostVoter::VIEW, $post);
109110
110111
// ...
111112
}
@@ -114,7 +115,7 @@ code like this:
114115
public function edit(Post $post): Response
115116
{
116117
// check for "edit" access: calls all voters
117-
$this->denyAccessUnlessGranted('edit', $post);
118+
$this->denyAccessUnlessGranted(PostVoter::EDIT, $post);
118119
119120
// ...
120121
}

0 commit comments

Comments
 (0)