Tutorial by Examples

You can create ACL by using Phalcon\Acl\Adapter\Memory class: $acl = new Phalcon\Acl\Adapter\Memory(); By default phalcon allows action to resource which has not been defined, to change this you can use: $acl->setDefaultAction(Phalcon\Acl::DENY); Roles can be added in two ways - using Pha...
You can allow role to access some action on resource by: $acl->allow('Administrator', 'products', 'create'); You can deny role to access some action on resource by: $acl->deny('Customer', 'categories', 'create'); You can check if role is allowed to some action on resource by using: $a...
You can add also add some more logic which has to be checked to your ACL using anonymous functions. They will be executed when using Phalcon\Acl\Adapter\Memory::allow() or Phalcon\Acl\Adapter\Memory::deny(), if they will return true, they role will be allowed to access certain action on resource. $...
By implementing Phalcon\Acl\RoleAware or Phalcon\Acl\ResourceAware you can use them as objects in Phalcon\Acl\Adapter\Memory::isAllowed(). // Create our class which will be used as roleName class UserRole implements Phalcon\Acl\RoleAware { protected $id; protected $roleName; publ...

Page 1 of 1