File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,7 +176,9 @@ public static function unifyRoute($route)
176176 */
177177 public static function getChildrenByType ($ itemName , $ childType )
178178 {
179- $ children = (new DbManager ())->getChildren ($ itemName );
179+ $ dbManager = Yii::$ app ->authManager instanceof DbManager ? : new DbManager ();
180+
181+ $ children = $ dbManager ->getChildren ($ itemName );
180182
181183 $ result = [];
182184
Original file line number Diff line number Diff line change 1010use webvimark \modules \UserManagement \models \rbacDB \search \PermissionSearch ;
1111use webvimark \components \AdminDefaultController ;
1212use webvimark \modules \UserManagement \UserManagementModule ;
13- use yii \db \Query ;
1413use Yii ;
15- use yii \rbac \DbManager ;
1614
1715class PermissionController extends AdminDefaultController
1816{
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public function actionView($id)
3232 {
3333 $ role = $ this ->findModel ($ id );
3434
35- $ authManager = new DbManager ();
35+ $ authManager = Yii:: $ app -> authManager instanceof DbManager ? : new DbManager ();
3636
3737 $ allRoles = Role::find ()
3838 ->asArray ()
@@ -72,7 +72,9 @@ public function actionSetChildRoles($id)
7272
7373 $ newChildRoles = Yii::$ app ->request ->post ('child_roles ' , []);
7474
75- $ children = (new DbManager ())->getChildren ($ role ->name );
75+ $ dbManager = Yii::$ app ->authManager instanceof DbManager ? : new DbManager ();
76+
77+ $ children = $ dbManager ->getChildren ($ role ->name );
7678
7779 $ oldChildRoles = [];
7880
@@ -108,7 +110,9 @@ public function actionSetChildPermissions($id)
108110
109111 $ newChildPermissions = Yii::$ app ->request ->post ('child_permissions ' , []);
110112
111- $ oldChildPermissions = array_keys ((new DbManager ())->getPermissionsByRole ($ role ->name ));
113+ $ dbManager = Yii::$ app ->authManager instanceof DbManager ? : new DbManager ();
114+
115+ $ oldChildPermissions = array_keys ($ dbManager ->getPermissionsByRole ($ role ->name ));
112116
113117 $ toRemove = array_diff ($ oldChildPermissions , $ newChildPermissions );
114118 $ toAdd = array_diff ($ newChildPermissions , $ oldChildPermissions );
Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ class Role extends AbstractItem
1818 */
1919 public static function getUserRoles ($ userId )
2020 {
21- return (new DbManager ())->getRolesByUser ($ userId );
21+ $ dbManager = Yii::$ app ->authManager instanceof DbManager ? : new DbManager ();
22+
23+ return $ dbManager ->getRolesByUser ($ userId );
2224 }
2325
2426 /**
@@ -31,7 +33,9 @@ public static function getUserRoles($userId)
3133 */
3234 public static function getPermissionsByRole ($ roleName , $ asArray = true )
3335 {
34- $ rbacPermissions = (new DbManager ())->getPermissionsByRole ($ roleName );
36+ $ dbManager = Yii::$ app ->authManager instanceof DbManager ? : new DbManager ();
37+
38+ $ rbacPermissions = $ dbManager ->getPermissionsByRole ($ roleName );
3539
3640 $ permissionNames = ArrayHelper::map ($ rbacPermissions , 'name ' , 'description ' );
3741
You can’t perform that action at this time.
0 commit comments