Conditions | 3 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
43 | public function __invoke(TokenInterface $token) |
||
44 | { |
||
45 | // extract and normalize roles from hierarchy |
||
46 | $roles = array_map( |
||
47 | function (Role $role) { |
||
48 | return $role->getRole(); |
||
49 | }, |
||
50 | $this->roleHierarchy->getReachableRoles($token->getRoles()) |
||
51 | ); |
||
52 | |||
53 | // iterating over all configured roles |
||
54 | // if a single role is missing this will return false |
||
55 | foreach ($this->roles as $role) { |
||
56 | if (!in_array($role, $roles, true)) { |
||
57 | return false; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | // all configured roles are accessible to the security token |
||
62 | // return true |
||
63 | |||
64 | return true; |
||
65 | } |
||
66 | } |
||
67 |