PHP Class Phalcon\Acl\Adapter\Redis

Manages ACL lists in Redis Database
Inheritance: extends Phalcon\Acl\Adapter
ファイルを表示 Open project: phalcon/incubator Class Usage Examples

Protected Properties

Property Type Description
$noArgumentsDefaultAction integer Default action for no arguments is allow
$redis Redis
$setNXAccess boolean

Public Methods

Method Description
__construct ( $redis = null )
addInherit ( string $roleName, Phalcon\Acl\Role | string $roleToInherit )
addResource ( Phalcon\Acl\Resource | string $resource, array | string $accessList = null ) : boolean {@inheritdoc} Example: Add a resource to the the list allowing access to an action $acl->addResource(new Phalcon\Acl\Resource('customers'), 'search'); $acl->addResource('customers', 'search'); Add a resource with an access list $acl->addResource(new Phalcon\Acl\Resource('customers'), ['create', 'search']); $acl->addResource('customers', ['create', 'search']);
addResourceAccess ( string $resourceName, array | string $accessList ) : boolean
addRole ( Phalcon\Acl\Role | string $role, string $accessInherits = null ) : boolean
allow ( string $role, string $resource, array | string $access, mixed $func = null ) {@inheritdoc} You can use '*' as wildcard Example: Allow access to guests to search on customers $acl->allow('guests', 'customers', 'search'); Allow access to guests to search or create on customers $acl->allow('guests', 'customers', ['search', 'create']); Allow access to any role to browse on products $acl->allow('*', 'products', 'browse'); Allow access to any role to browse on any resource $acl->allow('*', '*', 'browse');
deny ( $role, $resource, array | string $access, mixed $func = null ) {@inheritdoc} You can use '*' as wildcard Example: Deny access to guests to search on customers $acl->deny('guests', 'customers', 'search'); Deny access to guests to search or create on customers $acl->deny('guests', 'customers', ['search', 'create']); Deny access to any role to browse on products $acl->deny('*', 'products', 'browse'); Deny access to any role to browse on any resource $acl->deny('*', '*', 'browse');
dropResourceAccess ( string $resource, array | string $accessList )
getNoArgumentsDefaultAction ( ) : integer Returns the default ACL access level for no arguments provided in isAllowed action if there exists func for accessKey
getRedis ( )
getResourceAccess ( $resource )
getResources ( ) : Phalcon\Acl\Resource[]
getRoleInherits ( $role ) : array
getRoles ( ) : Phalcon\Acl\RoleInterface[]
isAllowed ( string $role, string $resource, string $access, array $parameters = null ) : boolean {@inheritdoc} Example: Does Andres have access to the customers resource to create? $acl->isAllowed('Andres', 'Products', 'create'); Do guests have access to any resource to edit? $acl->isAllowed('guests', '*', 'edit');
isResource ( string $resourceName ) : boolean
isResourceAccess ( $resource, $access )
isRole ( string $roleName ) : boolean
setNoArgumentsDefaultAction ( integer $defaultAccess ) Sets the default access level for no arguments provided in isAllowed action if there exists func for accessKey
setRedis ( $redis, $chainRedis = false )

Protected Methods

Method Description
allowOrDeny ( string $roleName, string $resourceName, array | string $access, integer $action ) Inserts/Updates a permission in the access list
resourcePermission ( $role, $access, $allowOrDeny )
rolePermission ( $resource, $access, $allowOrDeny )
setAccess ( $roleName, $resourceName, $accessName, $action ) : boolean

Method Details

__construct() public method

public __construct ( $redis = null )

addInherit() public method

public addInherit ( string $roleName, Phalcon\Acl\Role | string $roleToInherit )
$roleName string
$roleToInherit Phalcon\Acl\Role | string

addResource() public method

{@inheritdoc} Example: Add a resource to the the list allowing access to an action $acl->addResource(new Phalcon\Acl\Resource('customers'), 'search'); $acl->addResource('customers', 'search'); Add a resource with an access list $acl->addResource(new Phalcon\Acl\Resource('customers'), ['create', 'search']); $acl->addResource('customers', ['create', 'search']);
public addResource ( Phalcon\Acl\Resource | string $resource, array | string $accessList = null ) : boolean
$resource Phalcon\Acl\Resource | string
$accessList array | string
return boolean

addResourceAccess() public method

public addResourceAccess ( string $resourceName, array | string $accessList ) : boolean
$resourceName string
$accessList array | string
return boolean

addRole() public method

Example: $acl->addRole(new Phalcon\Acl\Role('administrator'), 'consultor'); $acl->addRole('administrator', 'consultor');
public addRole ( Phalcon\Acl\Role | string $role, string $accessInherits = null ) : boolean
$role Phalcon\Acl\Role | string
$accessInherits string
return boolean

allow() public method

{@inheritdoc} You can use '*' as wildcard Example: Allow access to guests to search on customers $acl->allow('guests', 'customers', 'search'); Allow access to guests to search or create on customers $acl->allow('guests', 'customers', ['search', 'create']); Allow access to any role to browse on products $acl->allow('*', 'products', 'browse'); Allow access to any role to browse on any resource $acl->allow('*', '*', 'browse');
public allow ( string $role, string $resource, array | string $access, mixed $func = null )
$role string
$resource string
$access array | string
$func mixed

allowOrDeny() protected method

Inserts/Updates a permission in the access list
protected allowOrDeny ( string $roleName, string $resourceName, array | string $access, integer $action )
$roleName string
$resourceName string
$access array | string
$action integer

deny() public method

{@inheritdoc} You can use '*' as wildcard Example: Deny access to guests to search on customers $acl->deny('guests', 'customers', 'search'); Deny access to guests to search or create on customers $acl->deny('guests', 'customers', ['search', 'create']); Deny access to any role to browse on products $acl->deny('*', 'products', 'browse'); Deny access to any role to browse on any resource $acl->deny('*', '*', 'browse');
public deny ( $role, $resource, array | string $access, mixed $func = null )
$access array | string
$func mixed

dropResourceAccess() public method

public dropResourceAccess ( string $resource, array | string $accessList )
$resource string
$accessList array | string

getNoArgumentsDefaultAction() public method

Returns the default ACL access level for no arguments provided in isAllowed action if there exists func for accessKey

getRedis() public method

public getRedis ( )

getResourceAccess() public method

public getResourceAccess ( $resource )

getResources() public method

public getResources ( ) : Phalcon\Acl\Resource[]
return Phalcon\Acl\Resource[]

getRoleInherits() public method

public getRoleInherits ( $role ) : array
$role
return array

getRoles() public method

public getRoles ( ) : Phalcon\Acl\RoleInterface[]
return Phalcon\Acl\RoleInterface[]

isAllowed() public method

{@inheritdoc} Example: Does Andres have access to the customers resource to create? $acl->isAllowed('Andres', 'Products', 'create'); Do guests have access to any resource to edit? $acl->isAllowed('guests', '*', 'edit');
public isAllowed ( string $role, string $resource, string $access, array $parameters = null ) : boolean
$role string
$resource string
$access string
$parameters array
return boolean

isResource() public method

public isResource ( string $resourceName ) : boolean
$resourceName string
return boolean

isResourceAccess() public method

public isResourceAccess ( $resource, $access )

isRole() public method

public isRole ( string $roleName ) : boolean
$roleName string
return boolean

resourcePermission() protected method

protected resourcePermission ( $role, $access, $allowOrDeny )
$role
$access
$allowOrDeny

rolePermission() protected method

protected rolePermission ( $resource, $access, $allowOrDeny )
$resource
$access
$allowOrDeny

setAccess() protected method

protected setAccess ( $roleName, $resourceName, $accessName, $action ) : boolean
$roleName
$resourceName
$accessName
$action
return boolean

setNoArgumentsDefaultAction() public method

Sets the default access level for no arguments provided in isAllowed action if there exists func for accessKey
public setNoArgumentsDefaultAction ( integer $defaultAccess )
$defaultAccess integer Phalcon\Acl::ALLOW or Phalcon\Acl::DENY

setRedis() public method

public setRedis ( $redis, $chainRedis = false )

Property Details

$noArgumentsDefaultAction protected_oe property

Default action for no arguments is allow
protected int $noArgumentsDefaultAction
return integer

$redis protected_oe property

protected Redis,Phalcon\Acl\Adapter $redis
return Redis

$setNXAccess protected_oe property

protected bool $setNXAccess
return boolean