Skip to content

Commit

Permalink
bug #5271 Fix nonexistent controller method (amansilla)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.3 branch.

Discussion
----------

Fix nonexistent controller method

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.3
| Fixed tickets | #5272

Commits
-------

10a8b23 [#5272] Fix unexistent controller method
  • Loading branch information
wouterj committed May 23, 2015
2 parents 03e29ad + 10a8b23 commit 2314cfe
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 2314cfe

Please sign in to comment.