File tree 1 file changed +10
-2
lines changed
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:
104
104
105
105
.. code-block :: php
106
106
107
+ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
108
+
109
+ // ...
110
+
107
111
/**
108
112
* @Route("/{id}/edit", name="admin_post_edit")
109
113
*/
@@ -117,7 +121,7 @@ the security checks in PHP:
117
121
}
118
122
119
123
if (!$post->isAuthor($this->getUser())) {
120
- throw $this->createAccessDeniedException ();
124
+ throw new AccessDeniedException ();
121
125
}
122
126
123
127
// ...
@@ -192,6 +196,10 @@ Now, you can use the voter with the ``security.context`` service:
192
196
193
197
.. code-block :: php
194
198
199
+ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
200
+
201
+ // ...
202
+
195
203
/**
196
204
* @Route("/{id}/edit", name="admin_post_edit")
197
205
*/
@@ -200,7 +208,7 @@ Now, you can use the voter with the ``security.context`` service:
200
208
$post = // query for the post ...
201
209
202
210
if (!$this->get('security.context')->isGranted('edit', $post)) {
203
- throw $this->createAccessDeniedException ();
211
+ throw new AccessDeniedException ();
204
212
}
205
213
}
206
214
You can’t perform that action at this time.
0 commit comments