PHP Class Phalcon\Acl\Adapter\Database

Inheritance: extends Phalcon\Acl\Adapter
Datei anzeigen Open project: phalcon/incubator

Protected Properties

Property Type Description
$accessList string Access List table
$connection Phalcon\Db\AdapterInterface
$noArgumentsDefaultAction integer Default action for no arguments is allow
$resources string Resources table
$resourcesAccesses string Resources Accesses table
$roles string Roles table
$rolesInherits string Roles Inherits table

Public Methods

Method Description
__construct ( array $options ) Class constructor.
addInherit ( string $roleName, 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 $roleName, string $resourceName, 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 ( string $roleName, string $resourceName, array | string $access, mixed $func = null ) : boolean {@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 $resourceName, array | string $accessList )
getNoArgumentsDefaultAction ( ) : integer Returns the default ACL access level for no arguments provided in isAllowed action if there exists func for accessKey
getResources ( ) : Phalcon\Acl\Resource[]
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
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

Protected Methods

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

Method Details

__construct() public method

Class constructor.
public __construct ( array $options )
$options array Adapter config

addInherit() public method

public addInherit ( string $roleName, string $roleToInherit )
$roleName string
$roleToInherit 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 $roleName, string $resourceName, array | string $access, mixed $func = null )
$roleName string
$resourceName 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 ( string $roleName, string $resourceName, array | string $access, mixed $func = null ) : boolean
$roleName string
$resourceName string
$access array | string
$func mixed
return boolean

dropResourceAccess() public method

public dropResourceAccess ( string $resourceName, array | string $accessList )
$resourceName 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

getResources() public method

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

getRoles() public method

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

insertOrUpdateAccess() protected method

Inserts/Updates a permission in the access list
protected insertOrUpdateAccess ( string $roleName, string $resourceName, string $accessName, integer $action ) : boolean
$roleName string
$resourceName string
$accessName string
$action integer
return boolean

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

isRole() public method

public isRole ( string $roleName ) : boolean
$roleName string
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

Property Details

$accessList protected_oe property

Access List table
protected string $accessList
return string

$connection protected_oe property

protected AdapterInterface,Phalcon\Db $connection
return Phalcon\Db\AdapterInterface

$noArgumentsDefaultAction protected_oe property

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

$resources protected_oe property

Resources table
protected string $resources
return string

$resourcesAccesses protected_oe property

Resources Accesses table
protected string $resourcesAccesses
return string

$roles protected_oe property

Roles table
protected string $roles
return string

$rolesInherits protected_oe property

Roles Inherits table
protected string $rolesInherits
return string