Skip to content

Commit

Permalink
bug symfony#5305 [BestPractices][Security] revert symfony#5271 on the…
Browse files Browse the repository at this point in the history
… 2.6 branch (xabbuh)

This PR was merged into the 2.6 branch.

Discussion
----------

[BestPractices][Security] revert symfony#5271 on the 2.6 branch

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.6+
| Fixed tickets | symfony#5271

Commits
-------

adf6f36 revert symfony#5271 on the 2.6 branch
  • Loading branch information
weaverryan committed May 23, 2015
2 parents f6b1b34 + adf6f36 commit e2d4986
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions best_practices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ more advanced use-case, you can always do the same security check in PHP:

.. code-block:: php
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
/**
* @Route("/{id}/edit", name="admin_post_edit")
*/
Expand All @@ -238,7 +234,16 @@ more advanced use-case, you can always do the same security check in PHP:
}
if (!$post->isAuthor($this->getUser())) {
throw new AccessDeniedException();
$this->denyAccessUnlessGranted('edit', $post);
// or without the shortcut:
//
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
//
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
// throw $this->createAccessDeniedException();
// }
}
// ...
Expand Down Expand Up @@ -327,10 +332,6 @@ via the even easier shortcut in a controller:

.. code-block:: php
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
/**
* @Route("/{id}/edit", name="admin_post_edit")
*/
Expand All @@ -342,6 +343,9 @@ via the even easier shortcut in a controller:
// or without the shortcut:
//
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ...
//
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
// throw $this->createAccessDeniedException();
// }
Expand Down

0 comments on commit e2d4986

Please sign in to comment.