gintonicweb / permissions
This package is abandoned and no longer maintained.
No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.
Permissions plugin for CakePHP
Package info
github.com/gintonicweb/permissions
Type:cakephp-plugin
pkg:composer/gintonicweb/permissions
dev-master
2016-05-07 08:09 UTC
Requires
- cakephp/cakephp: ~3.0
Requires (Dev)
This package is not auto-updated.
Last update: 2019-02-20 18:44:58 UTC
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);