18
18
use Casbin \Persist \FilteredAdapter ;
19
19
use Casbin \Persist \Adapters \Filter ;
20
20
use Casbin \Exceptions \InvalidFilterTypeException ;
21
+ use think \db \exception \DataNotFoundException ;
22
+ use think \db \exception \DbException ;
23
+ use think \db \exception \ModelNotFoundException ;
21
24
use think \facade \Db ;
22
25
use Casbin \WebmanPermission \Model \RuleModel ;
23
26
@@ -80,7 +83,7 @@ public function filterRule(array $rule): array
80
83
*
81
84
* @return void
82
85
*/
83
- public function savePolicyLine ($ ptype , array $ rule )
86
+ public function savePolicyLine (string $ ptype , array $ rule ): void
84
87
{
85
88
$ col ['ptype ' ] = $ ptype ;
86
89
foreach ($ rule as $ key => $ value ) {
@@ -93,6 +96,9 @@ public function savePolicyLine($ptype, array $rule)
93
96
* loads all policy rules from the storage.
94
97
*
95
98
* @param Model $model
99
+ * @throws DataNotFoundException
100
+ * @throws DbException
101
+ * @throws ModelNotFoundException
96
102
*/
97
103
public function loadPolicy (Model $ model ): void
98
104
{
@@ -168,7 +174,10 @@ public function addPolicies(string $sec, string $ptype, array $rules): void
168
174
*
169
175
* @param string $sec
170
176
* @param string $ptype
171
- * @param array $rule
177
+ * @param array $rule
178
+ * @throws DataNotFoundException
179
+ * @throws DbException
180
+ * @throws ModelNotFoundException
172
181
*/
173
182
public function removePolicy (string $ sec , string $ ptype , array $ rule ): void
174
183
{
@@ -205,12 +214,14 @@ public function removePolicies(string $sec, string $ptype, array $rules): void
205
214
}
206
215
207
216
/**
208
- * @param string $sec
209
- * @param string $ptype
210
- * @param int $fieldIndex
217
+ * @param string $sec
218
+ * @param string $ptype
219
+ * @param int $fieldIndex
211
220
* @param string|null ...$fieldValues
212
221
* @return array
213
- * @throws Throwable
222
+ * @throws DbException
223
+ * @throws ModelNotFoundException
224
+ * @throws DataNotFoundException
214
225
*/
215
226
public function _removeFilteredPolicy (string $ sec , string $ ptype , int $ fieldIndex , ?string ...$ fieldValues ): array
216
227
{
@@ -244,8 +255,11 @@ public function _removeFilteredPolicy(string $sec, string $ptype, int $fieldInde
244
255
*
245
256
* @param string $sec
246
257
* @param string $ptype
247
- * @param int $fieldIndex
258
+ * @param int $fieldIndex
248
259
* @param string ...$fieldValues
260
+ * @throws DataNotFoundException
261
+ * @throws DbException
262
+ * @throws ModelNotFoundException
249
263
*/
250
264
public function removeFilteredPolicy (string $ sec , string $ ptype , int $ fieldIndex , string ...$ fieldValues ): void
251
265
{
@@ -260,6 +274,9 @@ public function removeFilteredPolicy(string $sec, string $ptype, int $fieldIndex
260
274
* @param string $ptype
261
275
* @param string[] $oldRule
262
276
* @param string[] $newPolicy
277
+ * @throws DataNotFoundException
278
+ * @throws DbException
279
+ * @throws ModelNotFoundException
263
280
*/
264
281
public function updatePolicy (string $ sec , string $ ptype , array $ oldRule , array $ newPolicy ): void
265
282
{
@@ -342,6 +359,10 @@ public function setFiltered(bool $filtered): void
342
359
*
343
360
* @param Model $model
344
361
* @param mixed $filter
362
+ * @throws InvalidFilterTypeException
363
+ * @throws DataNotFoundException
364
+ * @throws DbException
365
+ * @throws ModelNotFoundException
345
366
*/
346
367
public function loadFilteredPolicy (Model $ model , $ filter ): void
347
368
{
@@ -351,7 +372,6 @@ public function loadFilteredPolicy(Model $model, $filter): void
351
372
$ instance = $ instance ->whereRaw ($ filter );
352
373
} elseif ($ filter instanceof Filter) {
353
374
foreach ($ filter ->p as $ k => $ v ) {
354
- $ where [$ v ] = $ filter ->g [$ k ];
355
375
$ instance = $ instance ->where ($ v , $ filter ->g [$ k ]);
356
376
}
357
377
} elseif ($ filter instanceof \Closure) {
0 commit comments