PHP Class SimpleAcl\Acl

ファイルを表示 Open project: alexshelkov/simpleacl Class Usage Examples

Protected Properties

Property Type Description
$ruleClass string Class name used when rule created from string.
$rules SimpleAcl\Rule[] Contains registered rules.

Public Methods

Method Description
addRule ( ) Adds rule.
getRuleClass ( ) : string Return rule class.
hasRule ( SimpleAcl\Rule | mixed $needRule ) : boolean Return true if rule was already added.
isAllowed ( string | SimpleAcl\Role\RoleAggregateInterface $roleName, string | SimpleAcl\Resource\ResourceAggregateInterface $resourceName, string $ruleName ) : boolean Checks is access allowed.
isAllowedReturnResult ( string | SimpleAcl\Role\RoleAggregateInterface $roleAggregate, string | SimpleAcl\Resource\ResourceAggregateInterface $resourceAggregate, string $ruleName ) : SimpleAcl\RuleResultCollection Checks is access allowed.
removeAllRules ( ) Remove all rules.
removeRule ( null | string $roleName = null, null | string $resourceName = null, null | string $ruleName = null, boolean $all = true ) Remove rules by rule name and (or) role and resource.
removeRuleById ( mixed $ruleId ) Removes rule by its id.
setRuleClass ( string $ruleClass ) Set rule class.

Protected Methods

Method Description
getNames ( string | SimpleAcl\Role\RoleAggregateInterface | SimpleAcl\Resource\ResourceAggregateInterface $object ) : array Get names.
isRuleAllow ( string $roleName, string $resourceName, $ruleName, SimpleAcl\RuleResultCollection $ruleResultCollection, string | SimpleAcl\Role\RoleAggregateInterface $roleAggregate, string | SimpleAcl\Resource\ResourceAggregateInterface $resourceAggregate ) Check is access allowed by some rule.

Method Details

addRule() public method

Assign $role, $resource and $action to added rule. If rule was already registered only change $role, $resource and $action for that rule. This method accept 1, 2, 3 or 4 arguments: addRule($rule) addRule($rule, $action) addRule($role, $resource, $rule) addRule($role, $resource, $rule, $action)
public addRule ( )

getNames() protected method

Get names.
protected getNames ( string | SimpleAcl\Role\RoleAggregateInterface | SimpleAcl\Resource\ResourceAggregateInterface $object ) : array
$object string | SimpleAcl\Role\RoleAggregateInterface | SimpleAcl\Resource\ResourceAggregateInterface
return array

getRuleClass() public method

Return rule class.
public getRuleClass ( ) : string
return string

hasRule() public method

Return true if rule was already added.
public hasRule ( SimpleAcl\Rule | mixed $needRule ) : boolean
$needRule SimpleAcl\Rule | mixed
return boolean

isAllowed() public method

Checks is access allowed.
public isAllowed ( string | SimpleAcl\Role\RoleAggregateInterface $roleName, string | SimpleAcl\Resource\ResourceAggregateInterface $resourceName, string $ruleName ) : boolean
$roleName string | SimpleAcl\Role\RoleAggregateInterface
$resourceName string | SimpleAcl\Resource\ResourceAggregateInterface
$ruleName string
return boolean

isAllowedReturnResult() public method

Checks is access allowed.
public isAllowedReturnResult ( string | SimpleAcl\Role\RoleAggregateInterface $roleAggregate, string | SimpleAcl\Resource\ResourceAggregateInterface $resourceAggregate, string $ruleName ) : SimpleAcl\RuleResultCollection
$roleAggregate string | SimpleAcl\Role\RoleAggregateInterface
$resourceAggregate string | SimpleAcl\Resource\ResourceAggregateInterface
$ruleName string
return SimpleAcl\RuleResultCollection

isRuleAllow() protected method

Returns null if rule don't match any role or resource.
protected isRuleAllow ( string $roleName, string $resourceName, $ruleName, SimpleAcl\RuleResultCollection $ruleResultCollection, string | SimpleAcl\Role\RoleAggregateInterface $roleAggregate, string | SimpleAcl\Resource\ResourceAggregateInterface $resourceAggregate )
$roleName string
$resourceName string
$ruleName
$ruleResultCollection SimpleAcl\RuleResultCollection
$roleAggregate string | SimpleAcl\Role\RoleAggregateInterface
$resourceAggregate string | SimpleAcl\Resource\ResourceAggregateInterface

removeAllRules() public method

Remove all rules.
public removeAllRules ( )

removeRule() public method

Remove rules by rule name and (or) role and resource.
public removeRule ( null | string $roleName = null, null | string $resourceName = null, null | string $ruleName = null, boolean $all = true )
$roleName null | string
$resourceName null | string
$ruleName null | string
$all boolean

removeRuleById() public method

Removes rule by its id.
public removeRuleById ( mixed $ruleId )
$ruleId mixed

setRuleClass() public method

Set rule class.
public setRuleClass ( string $ruleClass )
$ruleClass string

Property Details

$ruleClass protected_oe property

Class name used when rule created from string.
protected string $ruleClass
return string

$rules protected_oe property

Contains registered rules.
protected Rule[],SimpleAcl $rules
return SimpleAcl\Rule[]