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 @@ -2523,6 +2523,26 @@ that is thrown with the ``exceptionCode`` argument::
25232523 // ...
25242524 }
25252525
2526+ You can also extend the ``IsGranted `` attribute to create meaningful shortcuts::
2527+
2528+ // src/Security/Attribute/IsAdmin.php
2529+ // ...
2530+
2531+ use Symfony\Component\Security\Http\Attribute\IsGranted;
2532+
2533+ class IsAdmin extends IsGranted
2534+ {
2535+ public function __construct()
2536+ {
2537+ return parent::__construct('ROLE_ADMIN');
2538+ }
2539+ }
2540+
2541+ .. versionadded :: 7.4
2542+
2543+ The :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsGranted `
2544+ attribute is extendable since Symfony 7.4.
2545+
25262546.. _security-template :
25272547
25282548Access Control in Templates
You can’t perform that action at this time.
0 commit comments