|
1 | 1 | <?php |
2 | 2 | namespace githubjeka\rbac\controllers; |
3 | 3 |
|
| 4 | +use githubjeka\rbac\models\ItemForm; |
| 5 | +use Yii; |
4 | 6 | use yii\filters\ContentNegotiator; |
5 | 7 | use yii\filters\VerbFilter; |
| 8 | +use yii\helpers\ArrayHelper; |
| 9 | +use yii\rbac\Item; |
6 | 10 | use yii\web\Controller; |
7 | | -use Yii; |
8 | | -use githubjeka\rbac\models\ItemForm; |
9 | 11 | use yii\web\HttpException; |
10 | | -use yii\helpers\ArrayHelper; |
11 | 12 | use yii\web\Response; |
12 | 13 |
|
13 | 14 | /** |
@@ -45,19 +46,22 @@ public function behaviors() |
45 | 46 | */ |
46 | 47 | public function actionList() |
47 | 48 | { |
48 | | - $roles = Yii::$app->authManager->getRoles(); |
49 | | - $permissions = Yii::$app->authManager->getPermissions(); |
| 49 | + $authManager = Yii::$app->authManager; |
| 50 | + $roles = $authManager->getRoles(); |
| 51 | + $permissions = $authManager->getPermissions(); |
50 | 52 |
|
51 | 53 | $items = ArrayHelper::merge($roles, $permissions); |
| 54 | + $namesItems = array_keys($items); |
52 | 55 |
|
53 | 56 | $links = []; |
54 | 57 |
|
55 | | - $_keys = array_keys($items); |
56 | | - foreach ($items as $np => $oP) { |
57 | | - foreach ($c = Yii::$app->authManager->getChildren($np) as $nC => $oC) { |
| 58 | + foreach ($items as $nameItem => $item) { |
| 59 | + $children = $authManager->getChildren($nameItem); |
| 60 | + |
| 61 | + foreach ($children as $nameChild => $child) { |
58 | 62 | $links[] = [ |
59 | | - 'source' => array_search($np, $_keys), |
60 | | - 'target' => array_search($nC, $_keys), |
| 63 | + 'source' => array_search($nameItem, $namesItems), |
| 64 | + 'target' => array_search($nameChild, $namesItems), |
61 | 65 | ]; |
62 | 66 | } |
63 | 67 | } |
|
0 commit comments