Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,26 @@ that is thrown with the ``exceptionCode`` argument::
// ...
}

You can also extend the ``IsGranted`` attribute to create meaningful shortcuts::

// src/Security/Attribute/IsAdmin.php
// ...

use Symfony\Component\Security\Http\Attribute\IsGranted;

class IsAdmin extends IsGranted
{
public function __construct()
{
return parent::__construct('ROLE_ADMIN');
}
}

.. versionadded:: 7.4

The :class:`Symfony\\Component\\Security\\Http\\Attribute\\IsGranted`
attribute is extendable since Symfony 7.4.

.. _security-template:

Access Control in Templates
Expand Down