PHP 클래스 yii\rbac\PhpManager

The authorization data will be saved to and loaded from a file specified by [[authFile]], which defaults to 'protected/data/rbac.php'. PhpManager is mainly suitable for authorization data that is not too big (for example, the authorization data for a personal blog system). Use DbManager for more complex authorization data.
부터: 2.0
저자: Qiang Xue ([email protected])
저자: Alexander Kochetov ([email protected])
상속: extends yii\rbac\Manager
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$assignmentFile the path of the PHP script that contains the authorization assignments. This can be either a file path or a path alias to the file. Make sure this file is writable by the Web server process if the authorization needs to be changed online.
$itemFile the path of the PHP script that contains the authorization items. This can be either a file path or a path alias to the file. Make sure this file is writable by the Web server process if the authorization needs to be changed online.
$ruleFile the path of the PHP script that contains the authorization rules. This can be either a file path or a path alias to the file. Make sure this file is writable by the Web server process if the authorization needs to be changed online.

보호된 프로퍼티들

프로퍼티 타입 설명
$assignments array
$children array
$items Item[]
$rules Rule[]

공개 메소드들

메소드 설명
addChild ( $parent, $child )
assign ( $role, $userId )
canAddChild ( $parent, $child )
checkAccess ( $userId, $permissionName, $params = [] )
getAssignment ( $roleName, $userId )
getAssignments ( $userId )
getChildRoles ( $roleName )
getChildren ( $name )
getItem ( $name )
getItems ( $type )
getPermissionsByRole ( $roleName )
getPermissionsByUser ( $userId )
getRolesByUser ( $userId )
getRule ( $name )
getRules ( )
getUserIdsByRole ( $roleName )
hasChild ( $parent, $child )
init ( ) Initializes the application component.
removeAll ( )
removeAllAssignments ( )
removeAllPermissions ( )
removeAllRoles ( )
removeAllRules ( )
removeChild ( $parent, $child )
removeChildren ( $parent )
removeItem ( $item )
revoke ( $role, $userId )
revokeAll ( $userId )
updateRule ( $name, $rule )

보호된 메소드들

메소드 설명
addItem ( $item )
addRule ( $rule )
checkAccessRecursive ( string | integer $user, string $itemName, array $params, Assignment[] $assignments ) : boolean Performs access check for the specified user.
detectLoop ( Item $parent, Item $child ) : boolean Checks whether there is a loop in the authorization item hierarchy.
getChildrenRecursive ( string $name, array &$result ) Recursively finds all children and grand children of the specified item.
getDirectPermissionsByUser ( string | integer $userId ) : Permission[] Returns all permissions that are directly assigned to user.
getInheritedPermissionsByUser ( string | integer $userId ) : Permission[] Returns all permissions that the user inherits from the roles assigned to him.
invalidateScriptCache ( string $file ) Invalidates precompiled script cache (such as OPCache or APC) for the given file.
load ( ) Loads authorization data from persistent storage.
loadFromFile ( string $file ) : array Loads the authorization data from a PHP script file.
removeAllItems ( integer $type ) Removes all auth items of the specified type.
removeRule ( $rule )
save ( ) Saves authorization data into persistent storage.
saveAssignments ( ) Saves assignments data into persistent storage.
saveItems ( ) Saves items data into persistent storage.
saveRules ( ) Saves rules data into persistent storage.
saveToFile ( array $data, string $file ) Saves the authorization data to a PHP script file.
updateItem ( $name, $item )

메소드 상세

addChild() 공개 메소드

public addChild ( $parent, $child )

addItem() 보호된 메소드

protected addItem ( $item )

addRule() 보호된 메소드

protected addRule ( $rule )

assign() 공개 메소드

public assign ( $role, $userId )

canAddChild() 공개 메소드

부터: 2.0.8
public canAddChild ( $parent, $child )

checkAccess() 공개 메소드

public checkAccess ( $userId, $permissionName, $params = [] )

checkAccessRecursive() 보호된 메소드

This method is internally called by PhpManager::checkAccess.
protected checkAccessRecursive ( string | integer $user, string $itemName, array $params, Assignment[] $assignments ) : boolean
$user string | integer the user ID. This should can be either an integer or a string representing the unique identifier of a user. See [[\yii\web\User::id]].
$itemName string the name of the operation that need access check
$params array name-value pairs that would be passed to rules associated with the tasks and roles assigned to the user. A param with name 'user' is added to this array, which holds the value of `$userId`.
$assignments Assignment[] the assignments to the specified user
리턴 boolean whether the operations can be performed by the user.

detectLoop() 보호된 메소드

Checks whether there is a loop in the authorization item hierarchy.
protected detectLoop ( Item $parent, Item $child ) : boolean
$parent Item parent item
$child Item the child item that is to be added to the hierarchy
리턴 boolean whether a loop exists

getAssignment() 공개 메소드

public getAssignment ( $roleName, $userId )

getAssignments() 공개 메소드

public getAssignments ( $userId )

getChildRoles() 공개 메소드

public getChildRoles ( $roleName )

getChildren() 공개 메소드

public getChildren ( $name )

getChildrenRecursive() 보호된 메소드

Recursively finds all children and grand children of the specified item.
protected getChildrenRecursive ( string $name, array &$result )
$name string the name of the item whose children are to be looked for.
$result array the children and grand children (in array keys)

getDirectPermissionsByUser() 보호된 메소드

Returns all permissions that are directly assigned to user.
부터: 2.0.7
protected getDirectPermissionsByUser ( string | integer $userId ) : Permission[]
$userId string | integer the user ID (see [[\yii\web\User::id]])
리턴 Permission[] all direct permissions that the user has. The array is indexed by the permission names.

getInheritedPermissionsByUser() 보호된 메소드

Returns all permissions that the user inherits from the roles assigned to him.
부터: 2.0.7
protected getInheritedPermissionsByUser ( string | integer $userId ) : Permission[]
$userId string | integer the user ID (see [[\yii\web\User::id]])
리턴 Permission[] all inherited permissions that the user has. The array is indexed by the permission names.

getItem() 공개 메소드

public getItem ( $name )

getItems() 공개 메소드

public getItems ( $type )

getPermissionsByRole() 공개 메소드

public getPermissionsByRole ( $roleName )

getPermissionsByUser() 공개 메소드

public getPermissionsByUser ( $userId )

getRolesByUser() 공개 메소드

public getRolesByUser ( $userId )

getRule() 공개 메소드

public getRule ( $name )

getRules() 공개 메소드

public getRules ( )

getUserIdsByRole() 공개 메소드

부터: 2.0.7
public getUserIdsByRole ( $roleName )

hasChild() 공개 메소드

public hasChild ( $parent, $child )

init() 공개 메소드

This method overrides parent implementation by loading the authorization data from PHP script.
public init ( )

invalidateScriptCache() 보호된 메소드

Invalidates precompiled script cache (such as OPCache or APC) for the given file.
부터: 2.0.9
protected invalidateScriptCache ( string $file )
$file string the file path.

load() 보호된 메소드

Loads authorization data from persistent storage.
protected load ( )

loadFromFile() 보호된 메소드

Loads the authorization data from a PHP script file.
또한 보기: saveToFile()
protected loadFromFile ( string $file ) : array
$file string the file path.
리턴 array the authorization data

removeAll() 공개 메소드

public removeAll ( )

removeAllAssignments() 공개 메소드

removeAllItems() 보호된 메소드

Removes all auth items of the specified type.
protected removeAllItems ( integer $type )
$type integer the auth item type (either Item::TYPE_PERMISSION or Item::TYPE_ROLE)

removeAllPermissions() 공개 메소드

removeAllRoles() 공개 메소드

public removeAllRoles ( )

removeAllRules() 공개 메소드

public removeAllRules ( )

removeChild() 공개 메소드

public removeChild ( $parent, $child )

removeChildren() 공개 메소드

public removeChildren ( $parent )

removeItem() 공개 메소드

public removeItem ( $item )

removeRule() 보호된 메소드

protected removeRule ( $rule )

revoke() 공개 메소드

public revoke ( $role, $userId )

revokeAll() 공개 메소드

public revokeAll ( $userId )

save() 보호된 메소드

Saves authorization data into persistent storage.
protected save ( )

saveAssignments() 보호된 메소드

Saves assignments data into persistent storage.
protected saveAssignments ( )

saveItems() 보호된 메소드

Saves items data into persistent storage.
protected saveItems ( )

saveRules() 보호된 메소드

Saves rules data into persistent storage.
protected saveRules ( )

saveToFile() 보호된 메소드

Saves the authorization data to a PHP script file.
또한 보기: loadFromFile()
protected saveToFile ( array $data, string $file )
$data array the authorization data
$file string the file path.

updateItem() 보호된 메소드

protected updateItem ( $name, $item )

updateRule() 공개 메소드

public updateRule ( $name, $rule )

프로퍼티 상세

$assignmentFile 공개적으로 프로퍼티

the path of the PHP script that contains the authorization assignments. This can be either a file path or a path alias to the file. Make sure this file is writable by the Web server process if the authorization needs to be changed online.
또한 보기: loadFromFile()
또한 보기: saveToFile()
public $assignmentFile

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

protected array $assignments
리턴 array

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

protected array $children
리턴 array

$itemFile 공개적으로 프로퍼티

the path of the PHP script that contains the authorization items. This can be either a file path or a path alias to the file. Make sure this file is writable by the Web server process if the authorization needs to be changed online.
또한 보기: loadFromFile()
또한 보기: saveToFile()
public $itemFile

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

protected Item[],yii\rbac $items
리턴 Item[]

$ruleFile 공개적으로 프로퍼티

the path of the PHP script that contains the authorization rules. This can be either a file path or a path alias to the file. Make sure this file is writable by the Web server process if the authorization needs to be changed online.
또한 보기: loadFromFile()
또한 보기: saveToFile()
public $ruleFile

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

protected Rule[],yii\rbac $rules
리턴 Rule[]