Skip to content

Commit cb9660a

Browse files
Update expressions.rst
add complex is_granted and is_granted example
1 parent d13dce3 commit cb9660a

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)