Skip to content

Commit eceb5fa

Browse files
[Security] Add argument statusCode to #[IsGranted]
1 parent 9f38a74 commit eceb5fa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

security.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,20 @@ the ``ROLE_SUPER_ADMIN`` permission:
23062306
}
23072307
}
23082308
2309+
A custom status code can be set with the ``statusCode`` argument. This
2310+
code will be used in the response::
2311+
2312+
// src/Controller/AdminController.php
2313+
// ...
2314+
2315+
use Symfony\Component\Security\Http\Attribute\IsGranted;
2316+
2317+
#[IsGranted('ROLE_ADMIN', statusCode: 423)]
2318+
class AdminController extends AbstractController
2319+
{
2320+
// ...
2321+
}
2322+
23092323
.. versionadded:: 6.2
23102324

23112325
The ``#[IsGranted()]`` attribute was introduced in Symfony 6.2.

0 commit comments

Comments
 (0)