9
9
use Laminas \Db \TableGateway \TableGateway ;
10
10
use Laminas \Db \TableGateway \TableGatewayInterface ;
11
11
use Laminas \Db \Sql \Select ;
12
+ use Casbin \Model \Model ;
12
13
13
14
/**
14
15
* Laminas DB Adapter for Casbin.
@@ -92,7 +93,7 @@ public function savePolicyLine($ptype, array $rule)
92
93
*
93
94
* @param Model $model
94
95
*/
95
- public function loadPolicy ($ model )
96
+ public function loadPolicy ($ model ): void
96
97
{
97
98
$ rows = $ this ->tableGateway ->select (function (Select $ select ) {
98
99
$ select ->columns (['ptype ' , 'v0 ' , 'v1 ' , 'v2 ' , 'v3 ' , 'v4 ' , 'v5 ' ]);
@@ -113,21 +114,19 @@ public function loadPolicy($model)
113
114
*
114
115
* @return bool
115
116
*/
116
- public function savePolicy ($ model )
117
+ public function savePolicy ($ model ): void
117
118
{
118
- foreach ($ model-> model ['p ' ] as $ ptype => $ ast ) {
119
+ foreach ($ model ['p ' ] as $ ptype => $ ast ) {
119
120
foreach ($ ast ->policy as $ rule ) {
120
121
$ this ->savePolicyLine ($ ptype , $ rule );
121
122
}
122
123
}
123
124
124
- foreach ($ model-> model ['g ' ] as $ ptype => $ ast ) {
125
+ foreach ($ model ['g ' ] as $ ptype => $ ast ) {
125
126
foreach ($ ast ->policy as $ rule ) {
126
127
$ this ->savePolicyLine ($ ptype , $ rule );
127
128
}
128
129
}
129
-
130
- return true ;
131
130
}
132
131
133
132
/**
@@ -140,9 +139,9 @@ public function savePolicy($model)
140
139
*
141
140
* @return mixed
142
141
*/
143
- public function addPolicy ($ sec , $ ptype , $ rule )
142
+ public function addPolicy ($ sec , $ ptype , $ rule ): void
144
143
{
145
- return $ this ->savePolicyLine ($ ptype , $ rule );
144
+ $ this ->savePolicyLine ($ ptype , $ rule );
146
145
}
147
146
148
147
/**
@@ -152,7 +151,7 @@ public function addPolicy($sec, $ptype, $rule)
152
151
* @param string $ptype
153
152
* @param array $rule
154
153
*/
155
- public function removePolicy ($ sec , $ ptype , $ rule )
154
+ public function removePolicy ($ sec , $ ptype , $ rule ): void
156
155
{
157
156
$ where ['ptype ' ] = $ ptype ;
158
157
foreach ($ rule as $ key => $ value ) {
@@ -171,7 +170,7 @@ public function removePolicy($sec, $ptype, $rule)
171
170
* @param int $fieldIndex
172
171
* @param mixed ...$fieldValues
173
172
*/
174
- public function removeFilteredPolicy ($ sec , $ ptype , $ fieldIndex , ...$ fieldValues )
173
+ public function removeFilteredPolicy ($ sec , $ ptype , $ fieldIndex , ...$ fieldValues ): void
175
174
{
176
175
$ where ['ptype ' ] = $ ptype ;
177
176
foreach (range (0 , 5 ) as $ value ) {
0 commit comments