1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Casbin; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trait ManagementApi. |
9
|
|
|
* |
10
|
|
|
* @author [email protected] |
|
|
|
|
11
|
|
|
*/ |
|
|
|
|
12
|
|
|
trait ManagementApi |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* gets the list of subjects that show up in the current policy. |
|
|
|
|
16
|
|
|
* |
17
|
|
|
* @return array |
18
|
|
|
*/ |
19
|
6 |
|
public function getAllSubjects(): array |
20
|
|
|
{ |
21
|
6 |
|
return $this->model->getValuesForFieldInPolicyAllTypes('p', 0); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* gets the list of subjects that show up in the current named policy. |
|
|
|
|
26
|
|
|
* |
27
|
|
|
* @param string $ptype |
|
|
|
|
28
|
|
|
* |
29
|
|
|
* @return array |
30
|
|
|
*/ |
31
|
|
|
public function getAllNamedSubjects(string $ptype): array |
32
|
|
|
{ |
33
|
|
|
return $this->model->getValuesForFieldInPolicy('p', $ptype, 0); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* gets the list of objects that show up in the current policy. |
|
|
|
|
38
|
|
|
* |
39
|
|
|
* @return array |
40
|
|
|
*/ |
41
|
3 |
|
public function getAllObjects(): array |
42
|
|
|
{ |
43
|
3 |
|
return $this->model->getValuesForFieldInPolicyAllTypes('p', 1); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* gets the list of objects that show up in the current named policy. |
|
|
|
|
48
|
|
|
* |
49
|
|
|
* @param string $ptype |
|
|
|
|
50
|
|
|
* |
51
|
|
|
* @return array |
52
|
|
|
*/ |
53
|
|
|
public function getAllNamedObjects(string $ptype): array |
54
|
|
|
{ |
55
|
|
|
return $this->model->getValuesForFieldInPolicy('p', $ptype, 1); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* gets the list of actions that show up in the current policy. |
|
|
|
|
60
|
|
|
* |
61
|
|
|
* @return array |
62
|
|
|
*/ |
63
|
3 |
|
public function getAllActions(): array |
64
|
|
|
{ |
65
|
3 |
|
return $this->model->getValuesForFieldInPolicyAllTypes('p', 2); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* gets the list of actions that show up in the current named policy. |
|
|
|
|
70
|
|
|
* |
71
|
|
|
* @param string $ptype |
|
|
|
|
72
|
|
|
* |
73
|
|
|
* @return array |
74
|
|
|
*/ |
75
|
|
|
public function getAllNamedActions(string $ptype): array |
76
|
|
|
{ |
77
|
|
|
return $this->model->getValuesForFieldInPolicy('p', $ptype, 2); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* gets the list of roles that show up in the current policy. |
|
|
|
|
82
|
|
|
* |
83
|
|
|
* @return array |
84
|
|
|
*/ |
85
|
6 |
|
public function getAllRoles(): array |
86
|
|
|
{ |
87
|
6 |
|
return $this->model->getValuesForFieldInPolicyAllTypes('g', 1); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* gets the list of roles that show up in the current named policy. |
|
|
|
|
92
|
|
|
* |
93
|
|
|
* @param string $ptype |
|
|
|
|
94
|
|
|
* |
95
|
|
|
* @return array |
96
|
|
|
*/ |
97
|
|
|
public function getAllNamedRoles(string $ptype): array |
98
|
|
|
{ |
99
|
|
|
return $this->model->getValuesForFieldInPolicy('g', $ptype, 1); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* gets all the authorization rules in the policy. |
|
|
|
|
104
|
|
|
* |
105
|
|
|
* @return array |
106
|
|
|
*/ |
107
|
6 |
|
public function getPolicy(): array |
108
|
|
|
{ |
109
|
6 |
|
return $this->getNamedPolicy('p'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* gets all the authorization rules in the policy, field filters can be specified. |
|
|
|
|
114
|
|
|
* |
115
|
|
|
* @param int $fieldIndex |
|
|
|
|
116
|
|
|
* @param string ...$fieldValues |
|
|
|
|
117
|
|
|
* |
118
|
|
|
* @return array |
119
|
|
|
*/ |
120
|
15 |
|
public function getFilteredPolicy(int $fieldIndex, string ...$fieldValues): array |
121
|
|
|
{ |
122
|
15 |
|
return $this->getFilteredNamedPolicy('p', $fieldIndex, ...$fieldValues); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* gets all the authorization rules in the named policy. |
|
|
|
|
127
|
|
|
* |
128
|
|
|
* @param string $ptype |
|
|
|
|
129
|
|
|
* |
130
|
|
|
* @return array |
131
|
|
|
*/ |
132
|
6 |
|
public function getNamedPolicy(string $ptype): array |
133
|
|
|
{ |
134
|
6 |
|
return $this->model->getPolicy('p', $ptype); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* gets all the authorization rules in the named policy, field filters can be specified. |
|
|
|
|
139
|
|
|
* |
140
|
|
|
* @param string $ptype |
|
|
|
|
141
|
|
|
* @param int $fieldIndex |
|
|
|
|
142
|
|
|
* @param string ...$fieldValues |
|
|
|
|
143
|
|
|
* |
144
|
|
|
* @return array |
145
|
|
|
*/ |
146
|
15 |
|
public function getFilteredNamedPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): array |
147
|
|
|
{ |
148
|
15 |
|
return $this->model->getFilteredPolicy('p', $ptype, $fieldIndex, ...$fieldValues); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* gets all the role inheritance rules in the policy. |
|
|
|
|
153
|
|
|
* |
154
|
|
|
* @return array |
155
|
|
|
*/ |
156
|
3 |
|
public function getGroupingPolicy(): array |
157
|
|
|
{ |
158
|
3 |
|
return $this->getNamedGroupingPolicy('g'); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* gets all the role inheritance rules in the policy, field filters can be specified. |
|
|
|
|
163
|
|
|
* |
164
|
|
|
* @param int $fieldIndex |
|
|
|
|
165
|
|
|
* @param string ...$fieldValues |
|
|
|
|
166
|
|
|
* |
167
|
|
|
* @return array |
168
|
|
|
*/ |
169
|
3 |
|
public function getFilteredGroupingPolicy(int $fieldIndex, string ...$fieldValues): array |
170
|
|
|
{ |
171
|
3 |
|
return $this->getFilteredNamedGroupingPolicy('g', $fieldIndex, ...$fieldValues); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* gets all the role inheritance rules in the policy. |
|
|
|
|
176
|
|
|
* |
177
|
|
|
* @param string $ptype |
|
|
|
|
178
|
|
|
* |
179
|
|
|
* @return array |
180
|
|
|
*/ |
181
|
3 |
|
public function getNamedGroupingPolicy(string $ptype): array |
182
|
|
|
{ |
183
|
3 |
|
return $this->model->getPolicy('g', $ptype); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* gets all the role inheritance rules in the policy, field filters can be specified. |
|
|
|
|
188
|
|
|
* |
189
|
|
|
* @param string $ptype |
|
|
|
|
190
|
|
|
* @param int $fieldIndex |
|
|
|
|
191
|
|
|
* @param string ...$fieldValues |
|
|
|
|
192
|
|
|
* |
193
|
|
|
* @return array |
194
|
|
|
*/ |
195
|
3 |
|
public function getFilteredNamedGroupingPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): array |
196
|
|
|
{ |
197
|
3 |
|
return $this->model->getFilteredPolicy('g', $ptype, $fieldIndex, ...$fieldValues); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* determines whether an authorization rule exists. |
|
|
|
|
202
|
|
|
* |
203
|
|
|
* @param mixed ...$params |
|
|
|
|
204
|
|
|
* |
205
|
|
|
* @return bool |
206
|
|
|
*/ |
207
|
9 |
|
public function hasPolicy(...$params): bool |
208
|
|
|
{ |
209
|
9 |
|
return $this->hasNamedPolicy('p', ...$params); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* determines whether a named authorization rule exists. |
|
|
|
|
214
|
|
|
* |
215
|
|
|
* @param string $ptype |
|
|
|
|
216
|
|
|
* @param mixed ...$params |
|
|
|
|
217
|
|
|
* |
218
|
|
|
* @return bool |
219
|
|
|
*/ |
220
|
9 |
|
public function hasNamedPolicy(string $ptype, ...$params): bool |
221
|
|
|
{ |
222
|
9 |
|
if (1 == count($params) && is_array($params[0])) { |
223
|
6 |
|
$params = $params[0]; |
224
|
|
|
} |
225
|
|
|
|
226
|
9 |
|
return $this->model->hasPolicy('p', $ptype, $params); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* AddPolicy adds an authorization rule to the current policy. |
231
|
|
|
* If the rule already exists, the function returns false and the rule will not be added. |
232
|
|
|
* Otherwise the function returns true by adding the new rule. |
233
|
|
|
* |
234
|
|
|
* @param mixed ...$params |
|
|
|
|
235
|
|
|
* |
236
|
|
|
* @return bool |
237
|
|
|
*/ |
238
|
12 |
|
public function addPolicy(...$params): bool |
239
|
|
|
{ |
240
|
12 |
|
return $this->addNamedPolicy('p', ...$params); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* AddPolicies adds authorization rules to the current policy. |
245
|
|
|
* If the rule already exists, the function returns false for the corresponding rule and the rule will not be added. |
246
|
|
|
* Otherwise the function returns true for the corresponding rule by adding the new rule. |
247
|
|
|
* |
248
|
|
|
* @param array $rules |
|
|
|
|
249
|
|
|
* |
250
|
|
|
* @return bool |
251
|
|
|
*/ |
252
|
3 |
|
public function addPolicies(array $rules): bool |
253
|
|
|
{ |
254
|
3 |
|
return $this->addNamedPolicies('p', $rules); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* AddNamedPolicy adds an authorization rule to the current named policy. |
259
|
|
|
* If the rule already exists, the function returns false and the rule will not be added. |
260
|
|
|
* Otherwise the function returns true by adding the new rule. |
261
|
|
|
* |
262
|
|
|
* @param string $ptype |
|
|
|
|
263
|
|
|
* @param mixed ...$params |
|
|
|
|
264
|
|
|
* |
265
|
|
|
* @return bool |
266
|
|
|
*/ |
267
|
12 |
|
public function addNamedPolicy(string $ptype, ...$params): bool |
268
|
|
|
{ |
269
|
12 |
|
if (1 == count($params) && is_array($params[0])) { |
270
|
3 |
|
$params = $params[0]; |
271
|
|
|
} |
272
|
|
|
|
273
|
12 |
|
return $this->addPolicyInternal('p', $ptype, $params); |
|
|
|
|
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* AddNamedPolicies adds authorization rules to the current named policy. |
278
|
|
|
* If the rule already exists, the function returns false for the corresponding rule and the rule will not be added. |
279
|
|
|
* Otherwise the function returns true for the corresponding by adding the new rule. |
280
|
|
|
* |
281
|
|
|
* @param string $ptype |
|
|
|
|
282
|
|
|
* @param array $rules |
|
|
|
|
283
|
|
|
* |
284
|
|
|
* @return bool |
285
|
|
|
*/ |
286
|
3 |
|
public function addNamedPolicies(string $ptype, array $rules): bool |
287
|
|
|
{ |
288
|
3 |
|
return $this->addPoliciesInternal('p', $ptype, $rules); |
|
|
|
|
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* removes an authorization rule from the current policy. |
|
|
|
|
293
|
|
|
* |
294
|
|
|
* @param mixed ...$params |
|
|
|
|
295
|
|
|
* |
296
|
|
|
* @return bool |
297
|
|
|
*/ |
298
|
15 |
|
public function removePolicy(...$params): bool |
299
|
|
|
{ |
300
|
15 |
|
return $this->removeNamedPolicy('p', ...$params); |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* removes an authorization rules from the current policy. |
|
|
|
|
305
|
|
|
* |
306
|
|
|
* @param array $rules |
|
|
|
|
307
|
|
|
* |
308
|
|
|
* @return bool |
309
|
|
|
*/ |
310
|
3 |
|
public function removePolicies(array $rules): bool |
311
|
|
|
{ |
312
|
3 |
|
return $this->removeNamedPolicies('p', $rules); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* removes an authorization rule from the current policy, field filters can be specified. |
|
|
|
|
317
|
|
|
* |
318
|
|
|
* @param int $fieldIndex |
|
|
|
|
319
|
|
|
* @param string ...$fieldValues |
|
|
|
|
320
|
|
|
* |
321
|
|
|
* @return bool |
322
|
|
|
*/ |
323
|
15 |
|
public function removeFilteredPolicy(int $fieldIndex, string ...$fieldValues): bool |
324
|
|
|
{ |
325
|
15 |
|
return $this->removeFilteredNamedPolicy('p', $fieldIndex, ...$fieldValues); |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* removes an authorization rule from the current named policy. |
|
|
|
|
330
|
|
|
* |
331
|
|
|
* @param string $ptype |
|
|
|
|
332
|
|
|
* @param mixed ...$params |
|
|
|
|
333
|
|
|
* |
334
|
|
|
* @return bool |
335
|
|
|
*/ |
336
|
15 |
|
public function removeNamedPolicy(string $ptype, ...$params): bool |
337
|
|
|
{ |
338
|
15 |
|
if (1 == count($params) && is_array($params[0])) { |
339
|
3 |
|
$params = $params[0]; |
340
|
|
|
} |
341
|
|
|
|
342
|
15 |
|
return $this->removePolicyInternal('p', $ptype, $params); |
|
|
|
|
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* removes an authorization rules from the current named policy. |
|
|
|
|
347
|
|
|
* |
348
|
|
|
* @param string $ptype |
|
|
|
|
349
|
|
|
* @param array $rules |
|
|
|
|
350
|
|
|
* |
351
|
|
|
* @return bool |
352
|
|
|
*/ |
353
|
3 |
|
public function removeNamedPolicies(string $ptype, array $rules): bool |
354
|
|
|
{ |
355
|
3 |
|
return $this->removePoliciesInternal('p', $ptype, $rules); |
|
|
|
|
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* removes an authorization rule from the current named policy, field filters can be specified. |
|
|
|
|
360
|
|
|
* |
361
|
|
|
* @param string $ptype |
|
|
|
|
362
|
|
|
* @param int $fieldIndex |
|
|
|
|
363
|
|
|
* @param string ...$fieldValues |
|
|
|
|
364
|
|
|
* |
365
|
|
|
* @return bool |
366
|
|
|
*/ |
367
|
15 |
|
public function removeFilteredNamedPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): bool |
368
|
|
|
{ |
369
|
15 |
|
return $this->removeFilteredPolicyInternal('p', $ptype, $fieldIndex, ...$fieldValues); |
|
|
|
|
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* determines whether a role inheritance rule exists. |
|
|
|
|
374
|
|
|
* |
375
|
|
|
* @param mixed ...$params |
|
|
|
|
376
|
|
|
* |
377
|
|
|
* @return bool |
378
|
|
|
*/ |
379
|
3 |
|
public function hasGroupingPolicy(...$params): bool |
380
|
|
|
{ |
381
|
3 |
|
return $this->hasNamedGroupingPolicy('g', ...$params); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* determines whether a named role inheritance rule exists. |
|
|
|
|
386
|
|
|
* |
387
|
|
|
* @param string $ptype |
|
|
|
|
388
|
|
|
* @param mixed ...$params |
|
|
|
|
389
|
|
|
* |
390
|
|
|
* @return bool |
391
|
|
|
*/ |
392
|
3 |
|
public function hasNamedGroupingPolicy(string $ptype, ...$params): bool |
393
|
|
|
{ |
394
|
3 |
|
if (1 == count($params) && is_array($params[0])) { |
395
|
3 |
|
$params = $params[0]; |
396
|
|
|
} |
397
|
|
|
|
398
|
3 |
|
return $this->model->hasPolicy('g', $ptype, $params); |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* AddGroupingPolicy adds a role inheritance rule to the current policy. |
403
|
|
|
* If the rule already exists, the function returns false and the rule will not be added. |
404
|
|
|
* Otherwise the function returns true by adding the new rule. |
405
|
|
|
* |
406
|
|
|
* @param mixed ...$params |
|
|
|
|
407
|
|
|
* |
408
|
|
|
* @return bool |
409
|
|
|
*/ |
410
|
15 |
|
public function addGroupingPolicy(...$params): bool |
411
|
|
|
{ |
412
|
15 |
|
return $this->addNamedGroupingPolicy('g', ...$params); |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* AddGroupingPolicy adds a role inheritance rules to the current policy. |
417
|
|
|
* If the rule already exists, the function returns false and the rule will not be added. |
418
|
|
|
* Otherwise the function returns true by adding the new rule. |
419
|
|
|
* |
420
|
|
|
* @param array $rules |
|
|
|
|
421
|
|
|
* |
422
|
|
|
* @return bool |
423
|
|
|
*/ |
424
|
3 |
|
public function addGroupingPolicies(array $rules): bool |
425
|
|
|
{ |
426
|
3 |
|
return $this->addNamedGroupingPolicies('g', $rules); |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* AddNamedGroupingPolicy adds a named role inheritance rule to the current policy. |
431
|
|
|
* If the rule already exists, the function returns false and the rule will not be added. |
432
|
|
|
* Otherwise the function returns true by adding the new rule. |
433
|
|
|
* |
434
|
|
|
* @param string $ptype |
|
|
|
|
435
|
|
|
* @param mixed ...$params |
|
|
|
|
436
|
|
|
* |
437
|
|
|
* @return bool |
438
|
|
|
*/ |
439
|
15 |
|
public function addNamedGroupingPolicy(string $ptype, ...$params): bool |
440
|
|
|
{ |
441
|
15 |
|
if (1 == count($params) && is_array($params[0])) { |
442
|
3 |
|
$params = $params[0]; |
443
|
|
|
} |
444
|
|
|
|
445
|
15 |
|
$ruleAdded = $this->addPolicyInternal('g', $ptype, $params); |
446
|
|
|
|
447
|
15 |
|
if ($this->autoBuildRoleLinks) { |
448
|
15 |
|
$this->buildRoleLinks(); |
|
|
|
|
449
|
|
|
} |
450
|
|
|
|
451
|
15 |
|
return $ruleAdded; |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* AddNamedGroupingPolicy adds a named role inheritance rules to the current policy. |
456
|
|
|
* If the rule already exists, the function returns false and the rule will not be added. |
457
|
|
|
* Otherwise the function returns true by adding the new rule. |
458
|
|
|
* |
459
|
|
|
* @param string $ptype |
|
|
|
|
460
|
|
|
* @param array $rules |
|
|
|
|
461
|
|
|
* |
462
|
|
|
* @return bool |
463
|
|
|
*/ |
464
|
3 |
|
public function addNamedGroupingPolicies(string $ptype, array $rules): bool |
465
|
|
|
{ |
466
|
3 |
|
$ruleAdded = $this->addPoliciesInternal('g', $ptype, $rules); |
467
|
|
|
|
468
|
3 |
|
if ($this->autoBuildRoleLinks) { |
469
|
3 |
|
$this->buildRoleLinks(); |
470
|
|
|
} |
471
|
|
|
|
472
|
3 |
|
return $ruleAdded; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* removes a role inheritance rule from the current policy. |
|
|
|
|
477
|
|
|
* |
478
|
|
|
* @param mixed ...$params |
|
|
|
|
479
|
|
|
* |
480
|
|
|
* @return bool |
481
|
|
|
*/ |
482
|
12 |
|
public function removeGroupingPolicy(...$params): bool |
483
|
|
|
{ |
484
|
12 |
|
return $this->removeNamedGroupingPolicy('g', ...$params); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* removes a role inheritance rules from the current policy. |
|
|
|
|
489
|
|
|
* |
490
|
|
|
* @param array $rules |
|
|
|
|
491
|
|
|
* |
492
|
|
|
* @return bool |
493
|
|
|
*/ |
494
|
3 |
|
public function removeGroupingPolicies(array $rules): bool |
495
|
|
|
{ |
496
|
3 |
|
return $this->removeNamedGroupingPolicies('g', $rules); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* removes a role inheritance rule from the current policy, field filters can be specified. |
|
|
|
|
501
|
|
|
* |
502
|
|
|
* @param int $fieldIndex |
|
|
|
|
503
|
|
|
* @param string ...$fieldValues |
|
|
|
|
504
|
|
|
* |
505
|
|
|
* @return bool |
506
|
|
|
*/ |
507
|
12 |
|
public function removeFilteredGroupingPolicy(int $fieldIndex, string ...$fieldValues): bool |
508
|
|
|
{ |
509
|
12 |
|
return $this->removeFilteredNamedGroupingPolicy('g', $fieldIndex, ...$fieldValues); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* removes a role inheritance rule from the current named policy. |
|
|
|
|
514
|
|
|
* |
515
|
|
|
* @param string $ptype |
|
|
|
|
516
|
|
|
* @param mixed ...$params |
|
|
|
|
517
|
|
|
* |
518
|
|
|
* @return bool |
519
|
|
|
*/ |
520
|
12 |
|
public function removeNamedGroupingPolicy(string $ptype, ...$params): bool |
521
|
|
|
{ |
522
|
12 |
|
if (1 == count($params) && is_array($params[0])) { |
523
|
3 |
|
$params = $params[0]; |
524
|
|
|
} |
525
|
|
|
|
526
|
12 |
|
$ruleRemoved = $this->removePolicyInternal('g', $ptype, $params); |
527
|
|
|
|
528
|
12 |
|
if ($this->autoBuildRoleLinks) { |
529
|
12 |
|
$this->buildRoleLinks(); |
530
|
|
|
} |
531
|
|
|
|
532
|
12 |
|
return $ruleRemoved; |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* removes a role inheritance rules from the current named policy. |
|
|
|
|
537
|
|
|
* |
538
|
|
|
* @param string $ptype |
|
|
|
|
539
|
|
|
* @param array $rules |
|
|
|
|
540
|
|
|
* |
541
|
|
|
* @return bool |
542
|
|
|
*/ |
543
|
3 |
|
public function removeNamedGroupingPolicies(string $ptype, array $rules): bool |
544
|
|
|
{ |
545
|
3 |
|
$ruleRemoved = $this->removePoliciesInternal('g', $ptype, $rules); |
546
|
|
|
|
547
|
3 |
|
if ($this->autoBuildRoleLinks) { |
548
|
3 |
|
$this->buildRoleLinks(); |
549
|
|
|
} |
550
|
|
|
|
551
|
3 |
|
return $ruleRemoved; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* removes a role inheritance rule from the current named policy, field filters can be specified. |
|
|
|
|
556
|
|
|
* |
557
|
|
|
* @param string $ptype |
|
|
|
|
558
|
|
|
* @param int $fieldIndex |
|
|
|
|
559
|
|
|
* @param string ...$fieldValues |
|
|
|
|
560
|
|
|
* |
561
|
|
|
* @return bool |
562
|
|
|
*/ |
563
|
12 |
|
public function removeFilteredNamedGroupingPolicy(string $ptype, int $fieldIndex, string ...$fieldValues): bool |
564
|
|
|
{ |
565
|
12 |
|
$ruleRemoved = $this->removeFilteredPolicyInternal('g', $ptype, $fieldIndex, ...$fieldValues); |
566
|
|
|
|
567
|
12 |
|
if ($this->autoBuildRoleLinks) { |
568
|
12 |
|
$this->buildRoleLinks(); |
569
|
|
|
} |
570
|
|
|
|
571
|
12 |
|
return $ruleRemoved; |
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
/** |
575
|
|
|
* adds a customized function. |
|
|
|
|
576
|
|
|
* |
577
|
|
|
* @param string $name |
|
|
|
|
578
|
|
|
* @param \Closure $func |
|
|
|
|
579
|
|
|
*/ |
|
|
|
|
580
|
|
|
public function addFunction(string $name, \Closure $func): void |
581
|
|
|
{ |
582
|
|
|
$this->fm->addFunction($name, $func); |
583
|
|
|
} |
584
|
|
|
} |
585
|
|
|
|