Skip to content

Commit

Permalink
+ rbac/show action
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed May 27, 2016
1 parent f34dd8d commit ab0ccf7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/console/RbacController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use hipanel\rbac\Initer;
use Yii;
use yii\rbac\Item;

/**
* Class RbacController.
Expand All @@ -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";
}
}
}

0 comments on commit ab0ccf7

Please sign in to comment.