1 | <?php |
||
29 | class Service |
||
30 | { |
||
31 | /** |
||
32 | * @var Strategy The loading strategy |
||
33 | */ |
||
34 | private $strategy; |
||
35 | |||
36 | /** |
||
37 | * Creates a new Service. |
||
38 | * |
||
39 | * @param \Caridea\Acl\Strategy $strategy The loading strategy |
||
40 | */ |
||
41 | 9 | public function __construct(Strategy $strategy) |
|
45 | |||
46 | /** |
||
47 | * Asserts that one of the provided subjects can verb the Target. |
||
48 | * |
||
49 | * @param Subject[] $subjects An array of `Subject`s |
||
50 | * @param string $verb The verb (e.g. `read`, `create`, `delete`) |
||
51 | * @param \Caridea\Acl\Target $target The target |
||
52 | * @throws Exception\Forbidden if the subject cannot *verb* the Target |
||
53 | */ |
||
54 | 3 | public function assert(array $subjects, string $verb, Target $target) |
|
65 | |||
66 | /** |
||
67 | * Whether any of the provided subjects has permission to verb the Target. |
||
68 | * |
||
69 | * @param Subject[] $subjects An array of `Subject`s |
||
70 | * @param string $verb The verb (e.g. `read`, `create`, `delete`) |
||
71 | * @param \Caridea\Acl\Target $target The target |
||
72 | * @return bool Whether one of the subjects can *verb* the provided Target |
||
73 | */ |
||
74 | 2 | public function can(array $subjects, string $verb, Target $target): bool |
|
83 | |||
84 | /** |
||
85 | * Gets an access control list for a Target. |
||
86 | * |
||
87 | * @param Target $target The Target whose ACL will be loaded |
||
88 | * @param Subject[] $subjects An array of `Subject`s |
||
89 | * @return Acl The Acl found |
||
90 | * @throws Exception\Unloadable If the target provided is invalid |
||
91 | * @throws \InvalidArgumentException If the `subjects` argument contains invalid values |
||
92 | */ |
||
93 | 6 | public function get(Target $target, array $subjects): Acl |
|
97 | |||
98 | /** |
||
99 | * Gets access control lists for several Targets. |
||
100 | * |
||
101 | * @since 2.1.0 |
||
102 | * @param \Caridea\Acl\Target[] $targets The `Target` whose ACL will be loaded |
||
103 | * @param \Caridea\Acl\Subject[] $subjects An array of `Subject`s |
||
104 | * @return array<string,\Caridea\Acl\Acl> The loaded ACLs |
||
105 | * @throws \Caridea\Acl\Exception\Unloadable If the target provided is invalid |
||
106 | * @throws \InvalidArgumentException If the `targets` or `subjects` argument contains invalid values |
||
107 | */ |
||
108 | 3 | public function getAll(array $targets, array $subjects): array |
|
125 | } |
||
126 |