| 1 | <?php |
||
| 11 | class HasRoles |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Symfony's Security decision manager |
||
| 15 | * @var AccessDecisionManagerInterface |
||
| 16 | */ |
||
| 17 | private $decisionManager; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The roles that must be accessible. |
||
| 21 | * @var string[] |
||
| 22 | */ |
||
| 23 | private $roles; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param AccessDecisionManagerInterface $decisionManager The role hierarchy |
||
| 27 | * @param string[] $roles The roles that must be accessible |
||
| 28 | */ |
||
| 29 | 2 | public function __construct(AccessDecisionManagerInterface $decisionManager, $roles) |
|
| 34 | |||
| 35 | /** |
||
| 36 | * Check if the provided token has access to every configured roles. |
||
| 37 | * |
||
| 38 | * @param TokenInterface $token The security token |
||
| 39 | * |
||
| 40 | * @return bool Whether or not token has all configured roles |
||
| 41 | */ |
||
| 42 | 2 | public function __invoke(TokenInterface $token) |
|
| 46 | } |
||
| 47 |