\Ceo\Core\ManagersAclManager

Provides passthrough and simplified methods for ACL management

Managers provide a service layer in front of models. Managers implement domain specific logic, checks and initialization that would normally live in multiple controllers.

Summary

Methods
Properties
Constants
save()
getPaginator()
restDelete()
restCreate()
restUpdate()
find()
findFirst()
findFirstByName()
delete()
update()
create()
createResource()
createRole()
allow()
deny()
addResourceAction()
dropResourceAction()
getLists()
getActionsForRole()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

save()

save(object  $obj) : object

Save handler, because DRY

Parameters

object $obj

Model to be saved

Throws

\Ceo\Core\Managers\Exception

Json encoded string of validation errors

Returns

object —

Model

getPaginator()

getPaginator(integer  $page = 1, integer  $limit = 50) : \Ceo\Core\Managers\Ceo\Core\ModelHelpers\Paginator

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

Returns

\Ceo\Core\Managers\Ceo\Core\ModelHelpers\Paginator

restDelete()

restDelete(\Ceo\Core\Managers\number  $id) : boolean

Delete an object with rest

Parameters

\Ceo\Core\Managers\number $id

Throws

\Exception

Returns

boolean

restCreate()

restCreate(array  $data) 

Create a new object

Parameters

array $data

restUpdate()

restUpdate(integer  $id, array  $data) 

Update an existing object

Parameters

integer $id
array $data

find()

find(  $params = null) 

Parameters

$params

findFirst()

findFirst(  $params = null) 

Parameters

$params

findFirstByName()

findFirstByName(  $name) 

Parameters

$name

delete()

delete(string  $name) : boolean

Completely remove a role

Parameters

string $name

Returns

boolean

update()

update(  $name,   $input) 

Parameters

$name
$input

create()

create(  $input) 

Parameters

$input

createResource()

createResource(array  $input) : \Ceo\Core\Managers\Phalcon\Acl\Resource

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

Returns

\Ceo\Core\Managers\Phalcon\Acl\Resource

createRole()

createRole(array  $input) : boolean

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

Returns

boolean

allow()

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

deny()

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

addResourceAction()

addResourceAction(string  $resource, string  $action) 

Add action to resource

Parameters

string $resource
string $action

dropResourceAction()

dropResourceAction(string  $resource, string  $action) 

Remove an action from a resource

Parameters

string $resource
string $action

getLists()

getLists() : array

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

.. ]

Returns

array

getActionsForRole()

getActionsForRole(string  $role) : array

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

.. ]

Parameters

string $role

Returns

array