8000 some additional tweaks for the voter cookbook · symfony/symfony-docs@5d99884 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d99884

Browse files
committed
some additional tweaks for the voter cookbook
1 parent e3cbf35 commit 5d99884

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cookbook/security/voters_data_permission.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ edit a particular object. Here's an example implementation:
104104
105105
break;
106106
case self::EDIT:
107-
// we assume that our data object has a method getOwner() to
108-
// get the current owner user entity for this data object
107+
// this assumes that the data object has a method getOwner()
108+
// to get the entity of the user who owns this data object
109109
if ($user->getId() === $post->getOwner()->getId()) {
110110
return true;
111111
}
@@ -211,9 +211,7 @@ from the authorization checker is called.
211211
212212
$authChecker = $this->get('security.authorization_checker');
213213
214-
if (false === $authChecker->isGranted('view', $post)) {
215-
throw $this->createAccessDeniedException('Unauthorized access!');
216-
}
214+
$this->denyAccessUnlessGranted('view', $post, 'Unauthorized access!');
217215
218216
return new Response('<h1>'.$post->getName().'</h1>');
219217
}

0 commit comments

Comments
 (0)
0