| Conditions | 5 |
| Paths | 8 |
| Total Lines | 21 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public static function userHasAccess($panelName) |
||
| 22 | { |
||
| 23 | if (!isset(self::$viewRoles[$panelName])) { |
||
| 24 | self::$viewRoles[$panelName] = self::loadAllowRoles($panelName); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * if not defined allow rules, any has access |
||
| 29 | */ |
||
| 30 | if (!self::$viewRoles[$panelName]) { |
||
| 31 | return true; |
||
| 32 | } |
||
| 33 | |||
| 34 | foreach (self::$viewRoles[$panelName] as $role) { |
||
| 35 | if (\Yii::$app->user->can($role)) { |
||
| 36 | return true; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | return false; |
||
| 41 | } |
||
| 42 | |||
| 73 |