18
18
use Symfony \Component \DependencyInjection \ContainerAware ;
19
19
use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
20
20
use Symfony \Component \HttpKernel \HttpKernelInterface ;
21
+ use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
21
22
use Symfony \Component \Form \FormTypeInterface ;
22
23
use Symfony \Component \Form \Form ;
23
24
use Symfony \Component \Form \FormBuilder ;
@@ -139,8 +140,8 @@ public function stream($view, array $parameters = array(), StreamedResponse $res
139
140
*
140
141
* throw $this->createNotFoundException('Page not found!');
141
142
*
142
- * @param string $message A message
143
- * @param \Exception $previous The previous exception
143
+ * @param string $message A message
144
+ * @param \Exception|null $previous The previous exception
144
145
*
145
146
* @return NotFoundHttpException
146
147
*/
@@ -149,6 +150,23 @@ public function createNotFoundException($message = 'Not Found', \Exception $prev
149
150
return new NotFoundHttpException ($ message , $ previous );
150
151
}
151
152
153
+ /**
154
+ * Returns an AccessDeniedException.
155
+ *
156
+ * This will result in a 403 response code. Usage example:
157
+ *
158
+ * throw $this->createAccessDeniedException('Unable to access this page!');
159
+ *
160
+ * @param string $message A message
161
+ * @param \Exception|null $previous The previous exception
162
+ *
163
+ * @return AccessDeniedException
164
+ */
165
+ public function createAccessDeniedException ($ message = 'Access Denied ' , \Exception $ previous = null )
166
+ {
167
+ return new AccessDeniedException ($ message , $ previous );
168
+ }
169
+
152
170
/**
153
171
* Creates and returns a Form instance from the type of the form.
154
172
*
0 commit comments