PHP 클래스 Authority\Rule

Authority is an authorization library for CodeIgniter 2+ and PHPActiveRecord This library is inspired by, and largely based off, Ryan Bates' CanCan gem for Ruby on Rails. It is not a 1:1 port, but the essentials are available. Please check out his work at http://github.com/ryanb/cancan/
저자: Matthew Machuga
파일 보기 프로젝트 열기: machuga/authority 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$action Action the rule applies to
$behavior True defines a privilege, false defines a restriction
$conditions Array of conditions (closures) to check rule against

공개 메소드들

메소드 설명
__construct ( boolean $behavior, string $action, string | mixed $resource, Closure | null $condition = null ) Rule constructor
addCondition ( Closure $condition ) : void Add a condition for the rule to check against
getAction ( ) : string Returns action this rule represents
getBehavior ( ) : boolean Returns whether rule is a privilege or a restriction
getResource ( ) : mixed Returns resource this rule represents
isAllowed ( ) : boolean Determine if current rule allows access
isPrivilege ( ) : boolean Determine if rule is a privilege
isRelevant ( string $action, string | mixed $resource ) : boolean Determine if current rule is relevant based on an action and resource
isRestriction ( ) : boolean Determine if rule is a restriction
matchesAction ( string $action ) : boolean Determine if the instance's action matches the one passed in
matchesResource ( string | mixed $resource ) : boolean Determine if the instance's resource matches the one passed in
setAction ( string $action ) : void Set instance action
setBehavior ( boolean $behavior ) : void Set instance behavior
setResource ( string | mixed $resource ) : void Set instance resource
when ( $condition ) : void API friendly alias for addCondition

메소드 상세

__construct() 공개 메소드

Rule constructor
public __construct ( boolean $behavior, string $action, string | mixed $resource, Closure | null $condition = null )
$behavior boolean Determines if privilege or restriction
$action string Action the rule applies to
$resource string | mixed Name of resource or instance of object
$condition Closure | null Optional closure to act as a condition

addCondition() 공개 메소드

Add a condition for the rule to check against
public addCondition ( Closure $condition ) : void
$condition Closure Condition callback for rule to utilize
리턴 void

getAction() 공개 메소드

Returns action this rule represents
public getAction ( ) : string
리턴 string

getBehavior() 공개 메소드

Returns whether rule is a privilege or a restriction
public getBehavior ( ) : boolean
리턴 boolean

getResource() 공개 메소드

Returns resource this rule represents
public getResource ( ) : mixed
리턴 mixed

isAllowed() 공개 메소드

Determine if current rule allows access
public isAllowed ( ) : boolean
리턴 boolean

isPrivilege() 공개 메소드

Determine if rule is a privilege
public isPrivilege ( ) : boolean
리턴 boolean

isRelevant() 공개 메소드

Determine if current rule is relevant based on an action and resource
public isRelevant ( string $action, string | mixed $resource ) : boolean
$action string Action in question
$resource string | mixed Name of resource or instance of object
리턴 boolean

isRestriction() 공개 메소드

Determine if rule is a restriction
public isRestriction ( ) : boolean
리턴 boolean

matchesAction() 공개 메소드

Determine if the instance's action matches the one passed in
public matchesAction ( string $action ) : boolean
$action string Action in question
리턴 boolean

matchesResource() 공개 메소드

Determine if the instance's resource matches the one passed in
public matchesResource ( string | mixed $resource ) : boolean
$resource string | mixed Name of resource or instance of object
리턴 boolean

setAction() 공개 메소드

Set instance action
public setAction ( string $action ) : void
$action string Action for rule to use
리턴 void

setBehavior() 공개 메소드

Set instance behavior
public setBehavior ( boolean $behavior ) : void
$behavior boolean True for privilege, false for restriction
리턴 void

setResource() 공개 메소드

Set instance resource
public setResource ( string | mixed $resource ) : void
$resource string | mixed Set resource for rule to be checked against
리턴 void

when() 공개 메소드

API friendly alias for addCondition
public when ( $condition ) : void
리턴 void

프로퍼티 상세

$action 보호되어 있는 프로퍼티

Action the rule applies to
protected $action

$behavior 보호되어 있는 프로퍼티

True defines a privilege, false defines a restriction
protected $behavior

$conditions 보호되어 있는 프로퍼티

Array of conditions (closures) to check rule against
protected $conditions