File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments