没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Interface yii\rbac\ManagerInterface

继承yii\rbac\CheckAccessInterface
实现yii\rbac\BaseManager, yii\rbac\DbManager, yii\rbac\PhpManager
可用版本自2.0
源码 https://github.com/yiichina/yii2/blob/api/framework/rbac/ManagerInterface.php

For more details and usage information on ManagerInterface, see the guide article on security authorization.

公共方法

隐藏继承的方法

方法描述被定义在
add() Adds a role, permission or rule to the RBAC system. yii\rbac\ManagerInterface
addChild() Adds an item as a child of another item. yii\rbac\ManagerInterface
assign() Assigns a role to a user. yii\rbac\ManagerInterface
canAddChild() Checks the possibility of adding a child to parent. yii\rbac\ManagerInterface
checkAccess() 检查用户是否具有指定的权限。 yii\rbac\CheckAccessInterface
createPermission() Creates a new Permission object. yii\rbac\ManagerInterface
createRole() Creates a new Role object. yii\rbac\ManagerInterface
getAssignment() Returns the assignment information regarding a role and a user. yii\rbac\ManagerInterface
getAssignments() Returns all role assignment information for the specified user. yii\rbac\ManagerInterface
getChildRoles() Returns child roles of the role specified. Depth isn't limited. yii\rbac\ManagerInterface
getChildren() Returns the child permissions and/or roles. yii\rbac\ManagerInterface
getPermission() Returns the named permission. yii\rbac\ManagerInterface
getPermissions() Returns all permissions in the system. yii\rbac\ManagerInterface
getPermissionsByRole() Returns all permissions that the specified role represents. yii\rbac\ManagerInterface
getPermissionsByUser() Returns all permissions that the user has. yii\rbac\ManagerInterface
getRole() Returns the named role. yii\rbac\ManagerInterface
getRoles() Returns all roles in the system. yii\rbac\ManagerInterface
getRolesByUser() Returns the roles that are assigned to the user via assign(). yii\rbac\ManagerInterface
getRule() Returns the rule of the specified name. yii\rbac\ManagerInterface
getRules() Returns all rules available in the system. yii\rbac\ManagerInterface
getUserIdsByRole() Returns all user IDs assigned to the role specified. yii\rbac\ManagerInterface
hasChild() Returns a value indicating whether the child already exists for the parent. yii\rbac\ManagerInterface
remove() Removes a role, permission or rule from the RBAC system. yii\rbac\ManagerInterface
removeAll() Removes all authorization data, including roles, permissions, rules, and assignments. yii\rbac\ManagerInterface
removeAllAssignments() Removes all role assignments. yii\rbac\ManagerInterface
removeAllPermissions() Removes all permissions. yii\rbac\ManagerInterface
removeAllRoles() Removes all roles. yii\rbac\ManagerInterface
removeAllRules() Removes all rules. yii\rbac\ManagerInterface
removeChild() Removes a child from its parent. yii\rbac\ManagerInterface
removeChildren() Removed all children form their parent. yii\rbac\ManagerInterface
revoke() Revokes a role from a user. yii\rbac\ManagerInterface
revokeAll() Revokes all roles from a user. yii\rbac\ManagerInterface
update() Updates the specified role, permission or rule in the system. yii\rbac\ManagerInterface

方法详情

add() 公共 抽象 方法

Adds a role, permission or rule to the RBAC system.

public abstract boolean add($object)
$object yii\rbac\Role|yii\rbac\Permission|yii\rbac\Rule
return boolean

Whether the role, permission or rule is successfully added to the system

throws Exception

if data validation or saving fails (such as the name of the role or permission is not unique)

addChild() 公共 抽象 方法

Adds an item as a child of another item.

public abstract boolean addChild($parent, $child)
$parent yii\rbac\Item
$child yii\rbac\Item
return boolean

Whether the child successfully added

throws yii\base\Exception

if the parent-child relationship already exists or if a loop has been detected.

assign() 公共 抽象 方法

Assigns a role to a user.

public abstract yii\rbac\Assignment assign($role, $userId)
$role yii\rbac\Role|yii\rbac\Permission
$userId string|integer

The user ID (see yii\web\User::$id)

return yii\rbac\Assignment

The role assignment information.

throws Exception

if the role has already been assigned to the user

canAddChild() 公共 抽象 方法 (自版本 2.0.8 可用)

Checks the possibility of adding a child to parent.

public abstract boolean canAddChild($parent, $child)
$parent yii\rbac\Item

The parent item

$child yii\rbac\Item

The child item to be added to the hierarchy

return boolean

Possibility of adding

createPermission() 公共 抽象 方法

Creates a new Permission object.

Note that the newly created permission is not added to the RBAC system yet. You must fill in the needed data and call add() to add it to the system.

public abstract yii\rbac\Permission createPermission($name)
$name string

The permission name

return yii\rbac\Permission

The new Permission object

createRole() 公共 抽象 方法

Creates a new Role object.

Note that the newly created role is not added to the RBAC system yet. You must fill in the needed data and call add() to add it to the system.

public abstract yii\rbac\Role createRole($name)
$name string

The role name

return yii\rbac\Role

The new Role object

getAssignment() 公共 抽象 方法

Returns the assignment information regarding a role and a user.

public abstract null|yii\rbac\Assignment getAssignment($roleName, $userId)
$roleName string

The role name

$userId string|integer

The user ID (see yii\web\User::$id)

return null|yii\rbac\Assignment

The assignment information. Null is returned if the role is not assigned to the user.

getAssignments() 公共 抽象 方法

Returns all role assignment information for the specified user.

public abstract yii\rbac\Assignment[] getAssignments($userId)
$userId string|integer

The user ID (see yii\web\User::$id)

return yii\rbac\Assignment[]

The assignments indexed by role names. An empty array will be returned if there is no role assigned to the user.

getChildRoles() 公共 抽象 方法 (自版本 2.0.10 可用)

Returns child roles of the role specified. Depth isn't limited.

public abstract yii\rbac\Role[] getChildRoles($roleName)
$roleName string

Name of the role to file child roles for

return yii\rbac\Role[]

Child roles. The array is indexed by the role names. First element is an instance of the parent Role itself.

throws yii\base\InvalidParamException

if Role was not found that are getting by $roleName

getChildren() 公共 抽象 方法

Returns the child permissions and/or roles.

public abstract yii\rbac\Item[] getChildren($name)
$name string

The parent name

return yii\rbac\Item[]

The child permissions and/or roles

getPermission() 公共 抽象 方法

Returns the named permission.

public abstract null|yii\rbac\Permission getPermission($name)
$name string

The permission name.

return null|yii\rbac\Permission

The permission corresponding to the specified name. Null is returned if no such permission.

getPermissions() 公共 抽象 方法

Returns all permissions in the system.

public abstract yii\rbac\Permission[] getPermissions()
return yii\rbac\Permission[]

All permissions in the system. The array is indexed by the permission names.

getPermissionsByRole() 公共 抽象 方法

Returns all permissions that the specified role represents.

public abstract yii\rbac\Permission[] getPermissionsByRole($roleName)
$roleName string

The role name

return yii\rbac\Permission[]

All permissions that the role represents. The array is indexed by the permission names.

getPermissionsByUser() 公共 抽象 方法

Returns all permissions that the user has.

public abstract yii\rbac\Permission[] getPermissionsByUser($userId)
$userId string|integer

The user ID (see yii\web\User::$id)

return yii\rbac\Permission[]

All permissions that the user has. The array is indexed by the permission names.

getRole() 公共 抽象 方法

Returns the named role.

public abstract null|yii\rbac\Role getRole($name)
$name string

The role name.

return null|yii\rbac\Role

The role corresponding to the specified name. Null is returned if no such role.

getRoles() 公共 抽象 方法

Returns all roles in the system.

public abstract yii\rbac\Role[] getRoles()
return yii\rbac\Role[]

All roles in the system. The array is indexed by the role names.

getRolesByUser() 公共 抽象 方法

Returns the roles that are assigned to the user via assign().

Note that child roles that are not assigned directly to the user will not be returned.

public abstract yii\rbac\Role[] getRolesByUser($userId)
$userId string|integer

The user ID (see yii\web\User::$id)

return yii\rbac\Role[]

All roles directly assigned to the user. The array is indexed by the role names.

getRule() 公共 抽象 方法

Returns the rule of the specified name.

public abstract null|yii\rbac\Rule getRule($name)
$name string

The rule name

return null|yii\rbac\Rule

The rule object, or null if the specified name does not correspond to a rule.

getRules() 公共 抽象 方法

Returns all rules available in the system.

public abstract yii\rbac\Rule[] getRules()
return yii\rbac\Rule[]

The rules indexed by the rule names

getUserIdsByRole() 公共 抽象 方法 (自版本 2.0.7 可用)

Returns all user IDs assigned to the role specified.

public abstract array getUserIdsByRole($roleName)
$roleName string
return array

Array of user ID strings

hasChild() 公共 抽象 方法

Returns a value indicating whether the child already exists for the parent.

public abstract boolean hasChild($parent, $child)
$parent yii\rbac\Item
$child yii\rbac\Item
return boolean

Whether $child is already a child of $parent

remove() 公共 抽象 方法

Removes a role, permission or rule from the RBAC system.

public abstract boolean remove($object)
$object yii\rbac\Role|yii\rbac\Permission|yii\rbac\Rule
return boolean

Whether the role, permission or rule is successfully removed

removeAll() 公共 抽象 方法

Removes all authorization data, including roles, permissions, rules, and assignments.

public abstract void removeAll()
removeAllAssignments() 公共 抽象 方法

Removes all role assignments.

public abstract void removeAllAssignments()
removeAllPermissions() 公共 抽象 方法

Removes all permissions.

All parent child relations will be adjusted accordingly.

public abstract void removeAllPermissions()
removeAllRoles() 公共 抽象 方法

Removes all roles.

All parent child relations will be adjusted accordingly.

public abstract void removeAllRoles()
removeAllRules() 公共 抽象 方法

Removes all rules.

All roles and permissions which have rules will be adjusted accordingly.

public abstract void removeAllRules()
removeChild() 公共 抽象 方法

Removes a child from its parent.

Note, the child item is not deleted. Only the parent-child relationship is removed.

public abstract boolean removeChild($parent, $child)
$parent yii\rbac\Item
$child yii\rbac\Item
return boolean

Whether the removal is successful

removeChildren() 公共 抽象 方法

Removed all children form their parent.

Note, the children items are not deleted. Only the parent-child relationships are removed.

public abstract boolean removeChildren($parent)
$parent yii\rbac\Item
return boolean

Whether the removal is successful

revoke() 公共 抽象 方法

Revokes a role from a user.

public abstract boolean revoke($role, $userId)
$role yii\rbac\Role|yii\rbac\Permission
$userId string|integer

The user ID (see yii\web\User::$id)

return boolean

Whether the revoking is successful

revokeAll() 公共 抽象 方法

Revokes all roles from a user.

public abstract boolean revokeAll($userId)
$userId mixed

The user ID (see yii\web\User::$id)

return boolean

Whether the revoking is successful

update() 公共 抽象 方法

Updates the specified role, permission or rule in the system.

public abstract boolean update($name, $object)
$name string

The old name of the role, permission or rule

$object yii\rbac\Role|yii\rbac\Permission|yii\rbac\Rule
return boolean

Whether the update is successful

throws Exception

if data validation or saving fails (such as the name of the role or permission is not unique)