Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cookbook/security/voters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ edit a particular object. Here's an example implementation:

break;
case self::EDIT:
// we assume that our data object has a method getOwner() to
// get the current owner user entity for this data object
// this assumes that the data object has a getOwner() method
// to get the entity of the user who owns this data object
if ($user->getId() === $post->getOwner()->getId()) {
return true;
}
Expand Down Expand Up @@ -214,9 +214,7 @@ from the authorization checker is called.

$authChecker = $this->get('security.authorization_checker');

if (false === $authChecker->isGranted('view', $post)) {
throw $this->createAccessDeniedException('Unauthorized access!');
}
$this->denyAccessUnlessGranted('view', $post, 'Unauthorized access!');

return new Response('<h1>'.$post->getName().'</h1>');
}
Expand Down