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

Skip to content

Commit 10e022d

Browse files
committed
some additional tweaks for the voter cookbook
1 parent d5133bb commit 10e022d
8000

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cookbook/security/voters.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ edit a particular object. Here's an example implementation:
105105
106106
break;
107107
case self::EDIT:
108-
// we assume that our data object has a method getOwner() to
109-
// get the current owner user entity for this data object
108+
// this assumes that the data object has a getOwner() method
109+
// to get the entity of the user who owns this data object
110110
if ($user->getId() === $post->getOwner()->getId()) {
111111
return true;
112112
}
@@ -214,9 +214,7 @@ from the authorization checker is called.
214214
215215
$authChecker = $this->get('security.authorization_checker');
216216
217-
if (false === $authChecker->isGranted('view', $post)) {
218-
throw $this->createAccessDeniedException('Unauthorized access!');
219-
}
217+
$this->denyAccessUnlessGranted('view', $post, 'Unauthorized access!');
220218
221219
return new Response('<h1>'.$post->getName().'</h1>');
222220
}

0 commit comments

Comments
 (0)
0