class AclManager extends BaseManager

Provides passthrough and simplified methods for ACL management

Methods

object
save(object $obj)

Save handler, because DRY

Paginator
getPaginator(integer $page = 1, integer $limit = 50)

Helps paginate models using the query bulder. Bit more complicated than the native array method, but works better for larger data sets

boolean
restDelete(number $id)

Delete an object with rest

restCreate(array $data)

Create a new object

restUpdate(int $id, array $data)

Update an existing object

static 
find($params = null)

No description

static 
findFirst($params = null)

No description

static 
findFirstByName($name)

No description

boolean
delete(string $name)

Completely remove a role

update($name, $input)

No description

create($input)

No description

Resource
createResource(array $input)

Create a new ACL resource

boolean
createRole(array $input)

Create a role (group) for the ACL Data is provided as an array with * name * description (optional)

allow(string $role, string $resource, array $actions)

Allow action on resource

deny(string $role, string $resource, array $actions)

Deny action on resource

addResourceAction(string $resource, string $action)

Add action to resource

dropResourceAction(string $resource, string $action)

Remove an action from a resource

array
getLists()

Fetch all access control lists, organized by resource [ 'ResourceName' => ['action1', 'action2'], .

array
getActionsForRole(string $role)

Get all actions for a given role [ 'ResourceName' => [ ['action' => 'action1', 'allowed' => 0], ['action' => 'action2', 'allowed' => 1], ], .

Details

in BaseManager at line line 23
object save(object $obj)

Save handler, because DRY

Parameters

object $obj Model to be saved

Return Value

object Model

Exceptions

Exception Json encoded string of validation errors

in BaseManager at line line 60
Paginator getPaginator(integer $page = 1, integer $limit = 50)

Helps paginate models using the query bulder. Bit more complicated than the native array method, but works better for larger data sets

Because it's based on Phalcon's QueryBuilder, it supports a fluent filtering interface:

    $manager = $this->foo_manager;
    $items = $manager->getPaginator(1, 20)
        ->orderBy('created_at desc')
        ->where('name = :name:', array('name' => $name))
        ->andWhere('type = :type:', array('type' => $type))
        ->paginate();

    echo json_encode($items);

Parameters

integer $page Current page
integer $limit Per page limit

Return Value

Paginator

in BaseManager at line line 80
boolean restDelete(number $id)

Delete an object with rest

Parameters

number $id

Return Value

boolean

Exceptions

Exception

in BaseManager at line line 103
restCreate(array $data)

Create a new object

Parameters

array $data

in BaseManager at line line 117
restUpdate(int $id, array $data)

Update an existing object

Parameters

int $id
array $data

at line line 20
static find($params = null)

Parameters

$params

at line line 25
static findFirst($params = null)

Parameters

$params

at line line 30
static findFirstByName($name)

Parameters

$name

at line line 40
boolean delete(string $name)

Completely remove a role

Parameters

string $name

Return Value

boolean

at line line 53
update($name, $input)

Parameters

$name
$input

at line line 84
create($input)

Parameters

$input

at line line 138
Resource createResource(array $input)

Create a new ACL resource

Array contains: * name * actions

$manager = $di->get('acl_manager');
$manager->createResource([
    'name' => 'IndexResource',
    'actions' => ['index', 'create', '*']
]);

Parameters

array $input Input data

Return Value

Resource

at line line 181
boolean createRole(array $input)

Create a role (group) for the ACL Data is provided as an array with * name * description (optional)

 $manager = $di->get('core_manager')
 $manager->createRole([
     'name' => 'DefaultRole',
     'description' => 'Something here'
 ]);

Parameters

array $input Input data

Return Value

boolean

at line line 203
allow(string $role, string $resource, array $actions)

Allow action on resource

Parameters

string $role Role name
string $resource Resource name
array $actions Actions to allow

at line line 218
deny(string $role, string $resource, array $actions)

Deny action on resource

Parameters

string $role Role name
string $resource Resource name
array $actions Actions to deny

at line line 232
addResourceAction(string $resource, string $action)

Add action to resource

Parameters

string $resource
string $action

at line line 253
dropResourceAction(string $resource, string $action)

Remove an action from a resource

Parameters

string $resource
string $action

at line line 270
array getLists()

Fetch all access control lists, organized by resource [ 'ResourceName' => ['action1', 'action2'], .

.. ]

Return Value

array

at line line 305
array getActionsForRole(string $role)

Get all actions for a given role [ 'ResourceName' => [ ['action' => 'action1', 'allowed' => 0], ['action' => 'action2', 'allowed' => 1], ], .

.. ]

Parameters

string $role

Return Value

array