From a2d022b0d9b0ae5147e7bba11c0f15d7131cc6ec Mon Sep 17 00:00:00 2001 From: MarcomTeam Date: Tue, 20 May 2014 13:27:50 +0200 Subject: [PATCH 1/2] Update voters_data_permission.rst Strange $product variable... --- cookbook/security/voters_data_permission.rst | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cookbook/security/voters_data_permission.rst b/cookbook/security/voters_data_permission.rst index 7e2db803b36..2af09241734 100644 --- a/cookbook/security/voters_data_permission.rst +++ b/cookbook/security/voters_data_permission.rst @@ -204,20 +204,18 @@ from the security context is called. class PostController extends Controller { - public function showAction() + public function showAction($id) { // get a Post instance - $post = ...; + $post = $this->getDoctrine() + ->getRepository('AcmeStoreBundle:Post') + ->find($id); // keep in mind, this will call all registered security voters if (false === $this->get('security.context')->isGranted('view', $post)) { throw new AccessDeniedException('Unauthorised access!'); } - $product = $this->getDoctrine() - ->getRepository('AcmeStoreBundle:Post') - ->find($id); - return new Response('

'.$post->getName().'

'); } } From a392e789acd409c2225cfaa03ff430498849fe12 Mon Sep 17 00:00:00 2001 From: MarcomTeam Date: Wed, 21 May 2014 09:52:23 +0200 Subject: [PATCH 2/2] Update voters_data_permission.rst agreed --- cookbook/security/voters_data_permission.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cookbook/security/voters_data_permission.rst b/cookbook/security/voters_data_permission.rst index 2af09241734..f6f52904f7a 100644 --- a/cookbook/security/voters_data_permission.rst +++ b/cookbook/security/voters_data_permission.rst @@ -207,10 +207,8 @@ from the security context is called. public function showAction($id) { // get a Post instance - $post = $this->getDoctrine() - ->getRepository('AcmeStoreBundle:Post') - ->find($id); - + $post = ...; + // keep in mind, this will call all registered security voters if (false === $this->get('security.context')->isGranted('view', $post)) { throw new AccessDeniedException('Unauthorised access!');