1 | <?php |
||
19 | class PermissionConfig |
||
20 | { |
||
21 | protected $boolAllowances = []; |
||
22 | |||
23 | protected $roleAllowances = []; |
||
24 | |||
25 | protected $ownerAllowances = []; |
||
26 | |||
27 | /** |
||
28 | * Allows or forbids without any further check (use with care) |
||
29 | * |
||
30 | * @param string $resource Resource to allow |
||
31 | * @param bool $allowed Force true or false |
||
32 | * @return self |
||
33 | */ |
||
34 | public function allowAll(string $resource, bool $allowed = true): self |
||
40 | |||
41 | /** |
||
42 | * Allow the owner of the resource to access resource |
||
43 | * |
||
44 | * @param string $resource Resource to allow |
||
45 | * @return self |
||
46 | */ |
||
47 | public function allowOwner(string $resource): self |
||
53 | |||
54 | /** |
||
55 | * Allow role for resource |
||
56 | * |
||
57 | * @param string $resource Resource to allow |
||
58 | * @param array|string $role role |
||
59 | * @param array|string|null $object object |
||
60 | * @return self |
||
61 | */ |
||
62 | public function allowRole(string $resource, $role, $object = null): self |
||
68 | |||
69 | /** |
||
70 | * Get owner config |
||
71 | * |
||
72 | * @param string $resource Resource |
||
73 | * @return array |
||
74 | */ |
||
75 | public function getOwner(string $resource): array |
||
79 | |||
80 | /** |
||
81 | * Get roles config |
||
82 | * |
||
83 | * @param string $resource Resource |
||
84 | * @return array |
||
85 | */ |
||
86 | public function getRole(string $resource): array |
||
90 | |||
91 | /** |
||
92 | * Get forced config |
||
93 | * |
||
94 | * @param string $resource Resource |
||
95 | * @return Force|null |
||
96 | */ |
||
97 | public function getForce(string $resource): ?Force |
||
101 | } |
||
102 |