gintonicweb/permissions
Composer 安装命令:
composer require gintonicweb/permissions
包简介
Permissions plugin for CakePHP
README 文档
README
Permissions plugin for CakePHP
Warning
Do not use, very early stage
Installation
composer require gintonicweb/permissions
In your app's config/bootstrap.php add:
Plugin::load('Permissions');
Usage
In your Auth setup, use ConfigAuthorize for authorization.
public $components = array(
'Auth' => [
'authorize' => ['Permissions.Config'],
]
);
In your controllers you can now use an array like this to grant permissions to specific actions for specific roles
// Add Role at the top of your controller like this
// use Permissions\Model\Entity\Role;
public $_permissions = [
Role::ADMIN => '*',
Role::USER => ['index', 'view'],
];
You can also add the Roles Listener in bootstrap.php if you want to have access to the users role from the Auth component.
// in config/bootstrap.php
use Permissions\Listener\RoleListener;
EventManager::instance()->attach(new RoleListener());
which makes it possible now to do things like
$role = $this->Auth->user('role');
$roleName = Role::types($role);
统计信息
- 总下载量: 453
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-10-26