2017 © Pedro Peláez
 

library acl-php

Acl

image

matijabelec/acl-php

Acl

  • Tuesday, August 15, 2017
  • by matijabelec
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

acl-php

Packagist, (*1)

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)

Examples

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');

License

MIT (Matija Belec 2017), (*7)

The Versions

15/08 2017

dev-master

9999999-dev

Acl

  Sources   Download

MIT

The Development Requires

by Matija Belec

acl

15/08 2017

0.1.1

0.1.1.0

Acl

  Sources   Download

MIT

The Development Requires

by Matija Belec

acl

13/08 2017

0.1.0

0.1.0.0

Acl

  Sources   Download

MIT

The Development Requires

by Matija Belec

acl