File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2306,10 +2306,30 @@ the ``ROLE_SUPER_ADMIN`` permission:
2306
2306
}
2307
2307
}
2308
2308
2309
+ When using ``#[IsGranted()] ``, you can set the internal exception code
2310
+ of the :class: `Symfony\\ Component\\ Security\\ Core\\ Exception\\ AccessDeniedException `
2311
+ that is thrown, thanks to the ``exceptionCode `` argument::
2312
+
2313
+ // src/Controller/AdminController.php
2314
+ // ...
2315
+
2316
+ use Symfony\Component\Security\Http\Attribute\IsGranted;
2317
+
2318
+ #[IsGranted('ROLE_ADMIN', statusCode: 403, exceptionCode: 10010)]
2319
+ class AdminController extends AbstractController
2320
+ {
2321
+ // ...
2322
+ }
2323
+
2309
2324
.. versionadded :: 6.2
2310
2325
2311
2326
The ``#[IsGranted()] `` attribute was introduced in Symfony 6.2.
2312
2327
2328
+ .. versionaddedd :: 6.3
2329
+
2330
+ The ``exceptionCode `` argument of the ``#[IsGranted()] `` attribute was
2331
+ introduced in Symfony 6.3.
2332
+
2313
2333
.. _security-template :
2314
2334
2315
2335
Access Control in Templates
You can’t perform that action at this time.
0 commit comments