PHP 클래스 Authority\Authority

파일 보기 프로젝트 열기: machuga/authority 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$aliases List of aliases for groups of actions
$currentUser Current user in the application for rules to apply to
$dispatcher Dispatcher for events
$rules Collection of rules

공개 메소드들

메소드 설명
__construct ( mixed $currentUser, mixed $dispatcher = null ) Authority constructor
addAlias ( string $name, array $actions ) : authority\RuleAlias Define new alias for an action
addRule ( boolean $allow, array | string $actions, mixed $resource, Closure | null $condition = null ) : array | Rule Define rule for a given action and resource
allow ( array | string $actions, mixed $resource, Closure | null $condition = null ) : array | Rule Define privilege for a given action and resource
can ( $action, $resource, $resourceValue = null ) : boolean Determine if current user can access the given action and resource
cannot ( $action, $resource, $resourceValue = null ) : boolean Determine if current user cannot access the given action and resource Returns negation of can()
deny ( array | string $actions, mixed $resource, Closure | null $condition = null ) : array | Rule Define restriction for a given action and resource
dispatch ( string $eventName, mixed $payload = [] ) : mixed | null Fires event from current dispatcher
getAlias ( $name ) : authority\RuleAlias | null Returns a RuleAlias for a given action name
getAliases ( ) : array Returns all aliases
getAliasesForAction ( $action ) : array Returns all actions a given action applies to
getCurrentUser ( ) : mixed Returns current user
getRules ( ) : RuleRepository Returns the current rule set
getRulesFor ( $action, $resource ) : RuleRepository Returns all rules relevant to the given action and resource
setCurrentUser ( mixed $currentUser ) : void Set current user
setDispatcher ( mixed $dispatcher ) : void Set dispatcher
user ( ) : mixed Returns current user - alias of getCurrentUser()

메소드 상세

__construct() 공개 메소드

Authority constructor
public __construct ( mixed $currentUser, mixed $dispatcher = null )
$currentUser mixed Current user in the application
$dispatcher mixed Dispatcher used for firing events

addAlias() 공개 메소드

Define new alias for an action
public addAlias ( string $name, array $actions ) : authority\RuleAlias
$name string Name of action
$actions array Actions that $name aliases
리턴 authority\RuleAlias

addRule() 공개 메소드

Define rule for a given action and resource
public addRule ( boolean $allow, array | string $actions, mixed $resource, Closure | null $condition = null ) : array | Rule
$allow boolean True if privilege, false if restriction
$actions array | string Action for the rule
$resource mixed Resource for the rule
$condition Closure | null Optional condition for the rule
리턴 array | Rule

allow() 공개 메소드

Define privilege for a given action and resource
public allow ( array | string $actions, mixed $resource, Closure | null $condition = null ) : array | Rule
$actions array | string Action for the rule
$resource mixed Resource for the rule
$condition Closure | null Optional condition for the rule
리턴 array | Rule

can() 공개 메소드

Determine if current user can access the given action and resource
public can ( $action, $resource, $resourceValue = null ) : boolean
리턴 boolean

cannot() 공개 메소드

Determine if current user cannot access the given action and resource Returns negation of can()
public cannot ( $action, $resource, $resourceValue = null ) : boolean
리턴 boolean

deny() 공개 메소드

Define restriction for a given action and resource
public deny ( array | string $actions, mixed $resource, Closure | null $condition = null ) : array | Rule
$actions array | string Action for the rule
$resource mixed Resource for the rule
$condition Closure | null Optional condition for the rule
리턴 array | Rule

dispatch() 공개 메소드

Fires event from current dispatcher
public dispatch ( string $eventName, mixed $payload = [] ) : mixed | null
$eventName string
$payload mixed
리턴 mixed | null

getAlias() 공개 메소드

Returns a RuleAlias for a given action name
public getAlias ( $name ) : authority\RuleAlias | null
리턴 authority\RuleAlias | null

getAliases() 공개 메소드

Returns all aliases
public getAliases ( ) : array
리턴 array

getAliasesForAction() 공개 메소드

Returns all actions a given action applies to
public getAliasesForAction ( $action ) : array
리턴 array

getCurrentUser() 공개 메소드

Returns current user
public getCurrentUser ( ) : mixed
리턴 mixed

getRules() 공개 메소드

Returns the current rule set
public getRules ( ) : RuleRepository
리턴 RuleRepository

getRulesFor() 공개 메소드

Returns all rules relevant to the given action and resource
public getRulesFor ( $action, $resource ) : RuleRepository
리턴 RuleRepository

setCurrentUser() 공개 메소드

Set current user
public setCurrentUser ( mixed $currentUser ) : void
$currentUser mixed Current user in the application
리턴 void

setDispatcher() 공개 메소드

Set dispatcher
public setDispatcher ( mixed $dispatcher ) : void
$dispatcher mixed Dispatcher to fire events
리턴 void

user() 공개 메소드

Returns current user - alias of getCurrentUser()
public user ( ) : mixed
리턴 mixed

프로퍼티 상세

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

List of aliases for groups of actions
protected $aliases

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

Current user in the application for rules to apply to
protected $currentUser

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

Dispatcher for events
protected $dispatcher

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

Collection of rules
protected $rules