Skip to content

Commit 10a8b23

Browse files
author
Antonio Mansilla
committed
[#5272] Fix unexistent controller method
1 parent 4127197 commit 10a8b23

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

best_practices/security.rst

+10-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ the security checks in PHP:
104104

105105
.. code-block:: php
106106
107+
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
108+
109+
// ...
110+
107111
/**
108112
* @Route("/{id}/edit", name="admin_post_edit")
109113
*/
@@ -117,7 +121,7 @@ the security checks in PHP:
117121
}
118122
119123
if (!$post->isAuthor($this->getUser())) {
120-
throw $this->createAccessDeniedException();
124+
throw new AccessDeniedException();
121125
}
122126
123127
// ...
@@ -192,6 +196,10 @@ Now, you can use the voter with the ``security.context`` service:
192196

193197
.. code-block:: php
194198
199+
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
200+
201+
// ...
202+
195203
/**
196204
* @Route("/{id}/edit", name="admin_post_edit")
197205
*/
@@ -200,7 +208,7 @@ Now, you can use the voter with the ``security.context`` service:
200208
$post = // query for the post ...
201209
202210
if (!$this->get('security.context')->isGranted('edit', $post)) {
203-
throw $this->createAccessDeniedException();
211+
throw new AccessDeniedException();
204212
}
205213
}
206214

0 commit comments

Comments
 (0)