1 | <?php |
||
8 | final class RoleAuthorization implements AuthorizationInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private $roleHierarchy; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | private $cachedResolvedHierarchies; |
||
19 | |||
20 | /** |
||
21 | * @param array $roleHierarchy |
||
22 | */ |
||
23 | public function __construct(array $roleHierarchy = []) |
||
27 | |||
28 | /** |
||
29 | * @param UserInterface $user |
||
30 | * @param mixed $attributes |
||
31 | * @param ModelInterface|null $model |
||
32 | * |
||
33 | * @return bool |
||
34 | */ |
||
35 | public function isGranted(UserInterface $user, $attributes, ModelInterface $model = null): bool |
||
42 | |||
43 | /** |
||
44 | * @param UserInterface $user |
||
45 | * |
||
46 | * @return array |
||
47 | */ |
||
48 | private function getOwningRoles(UserInterface $user): array |
||
59 | |||
60 | /** |
||
61 | * @param array $roles |
||
62 | * @param array $alreadySolvedRoles |
||
63 | * |
||
64 | * @return array |
||
65 | */ |
||
66 | private function resolveRoleHierarchy(array $roles, array $alreadySolvedRoles = []): array |
||
82 | |||
83 | /** |
||
84 | * @param mixed $attributes |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | private function getNeededRoles($attributes): array |
||
92 | |||
93 | /** |
||
94 | * @param array $owningRoles |
||
95 | * @param array $neededRoles |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | private function checkRoles(array $owningRoles, array $neededRoles): bool |
||
109 | } |
||
110 |