Skip to content

Commit

Permalink
[#5272] Fix unexistent controller method
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Mansilla committed May 19, 2015
1 parent 4127197 commit 10a8b23
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions best_practices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ the security checks in PHP:

.. code-block:: php
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
/**
* @Route("/{id}/edit", name="admin_post_edit")
*/
Expand All @@ -117,7 +121,7 @@ the security checks in PHP:
}
if (!$post->isAuthor($this->getUser())) {
throw $this->createAccessDeniedException();
throw new AccessDeniedException();
}
// ...
Expand Down Expand Up @@ -192,6 +196,10 @@ Now, you can use the voter with the ``security.context`` service:

.. code-block:: php
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
/**
* @Route("/{id}/edit", name="admin_post_edit")
*/
Expand All @@ -200,7 +208,7 @@ Now, you can use the voter with the ``security.context`` service:
$post = // query for the post ...
if (!$this->get('security.context')->isGranted('edit', $post)) {
throw $this->createAccessDeniedException();
throw new AccessDeniedException();
}
}
Expand Down

0 comments on commit 10a8b23

Please sign in to comment.