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"; + } } }