From ab0ccf721db90a0764b9fa834915f4a3c6174203 Mon Sep 17 00:00:00 2001 From: Andrii Vasyliev Date: Fri, 27 May 2016 19:19:02 +0000 Subject: [PATCH] + rbac/show action --- src/console/RbacController.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/console/RbacController.php b/src/console/RbacController.php index 40b4034..0ebde1d 100644 --- a/src/console/RbacController.php +++ b/src/console/RbacController.php @@ -13,6 +13,7 @@ use hipanel\rbac\Initer; use Yii; +use yii\rbac\Item; /** * Class RbacController. @@ -24,9 +25,24 @@ class RbacController extends \yii\console\Controller public function actionInit() { $auth = Yii::$app->get('authManager'); + $auth->setAssignment('freezer', 'sol'); Initer::init($auth); + } + + public function actionShow() + { + $auth = Yii::$app->get('authManager'); + + echo "Permissions:\n"; + foreach ($auth->getItems(Item::TYPE_PERMISSION) as $name => $perm) { + echo "\t$perm->name $perm->description\n"; + } - $auth->save(); + echo "Roles:\n"; + foreach ($auth->getItems(Item::TYPE_ROLE) as $name => $role) { + $children = implode(',', array_keys($auth->getChildren($name))); + echo "\t$role->name [$children] $role->description\n"; + } } }