File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2523,6 +2523,28 @@ that is thrown with the ``exceptionCode`` argument::
25232523 // ...
25242524 }
25252525
2526+ Extending ``IsGranted ``
2527+ .......................
2528+
2529+ You can also extend the ``IsGranted `` class to create new attributes:
2530+
2531+ // src/Security/Attribute/IsAdmin.php
2532+ // ...
2533+
2534+ use Symfony\C omponent\S ecurity\H ttp\A ttribute\I sGranted;
2535+
2536+ class IsAdmin extends IsGranted
2537+ {
2538+ public function __construct() {
2539+ return parent::__construct('ROLE_ADMIN');
2540+ }
2541+ }
2542+
2543+ .. versionadded :: 7.4
2544+
2545+ The :class: `Symfony\\ Component\\ Security\\ Http\\ Attribute\\ IsGranted `
2546+ attribute is extendable since Symfony 7.4.
2547+
25262548.. _security-template :
25272549
25282550Access Control in Templates
You can’t perform that action at this time.
0 commit comments