dev-master
9999999-devAcl
MIT
The Development Requires
by Matija Belec
acl
0.1.1
0.1.1.0Acl
MIT
The Development Requires
by Matija Belec
acl
0.1.0
0.1.0.0Acl
MIT
The Development Requires
by Matija Belec
acl
Wallogit.com
2017 © Pedro Peláez
Acl
Custom ACL with role hierarchy (any role can have max. of 1 parent role). Role hierarchy is used to automatically inherit actions allowed for parent(s) roles to selected role. Actions are just strings that describes some action. Roles are, basically, strings that represents types of users (but not limited to)., (*2)
Before anything else, create an object of MatijaBelec\Acl\Acl class., (*3)
use MatijaBelec\Acl\Acl;
$acl = new Acl();
There should be created role hierarchy. It can be created with the following code:, (*4)
// create role hierarchy
$acl->addRole('guest');
$acl->addRole('user', 'guest');
$acl->addRole('administrator', 'user');
After role hierarchy is created, let's add some actions to roles:, (*5)
// create actions tree
$acl->allow('guest', 'user.canUpdate');
$acl->allow('guest', 'user.canDelete');
$acl->allow('user', 'user.canCreate');
$acl->deny('user', 'user.canDelete');
$acl->allow('administrator', ['user.canRead', 'user.canUpdate']);
$acl->allow('administrator', 'user.canDelete');
To check if some role has allowed actions, the following code can be used:, (*6)
// check actions on user
$adminIsAllowedToGetUserDetails = $acl->isAllowed('administrator', 'user.canRead');
$userIsAllowedToCreateNewUser = $acl->isAllowed('user', 'user.canCreate');
MIT (Matija Belec 2017), (*7)
Acl
MIT
acl
Acl
MIT
acl
Acl
MIT
acl