Skip to content

Commit 8e2b228

Browse files
committed
minor #17829 [Security] Add complex example is_granted and/or is_granted (andreybolonin)
This PR was merged into the 6.2 branch. Discussion ---------- [Security] Add complex example is_granted and/or is_granted Add complex example is_granted and/or is_granted <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- cb9660a Update expressions.rst
2 parents 69b9355 + cb9660a commit 8e2b228

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

security/expressions.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ and ``#[IsGranted()]`` attribute also accept an
3434
// ...
3535
}
3636
}
37+
.. code-block:: php-attributes
38+
39+
// src/Controller/MyController.php
40+
namespace App\Controller;
41+
42+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
43+
use Symfony\Component\ExpressionLanguage\Expression;
44+
use Symfony\Component\HttpFoundation\Response;
45+
46+
class MyController extends AbstractController
47+
{
48+
#[IsGranted(new Expression('is_granted("ROLE_ADMIN") or is_granted("ROLE_MANAGER")'))]
49+
public function index(): Response
50+
{
51+
// ...
52+
}
53+
}
3754
3855
.. code-block:: php
3956

0 commit comments

Comments
 (0)