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