PHP Интерфейс yii\rbac\ManagerInterface

С версии: 2.0
Автор: Qiang Xue ([email protected])
Показать файл Открыть проект Примеры использования интерфейса

Открытые методы

Метод Описание
add ( Role | Permission | Rule $object ) : boolean Adds a role, permission or rule to the RBAC system.
addChild ( Item $parent, Item $child ) : boolean Adds an item as a child of another item.
assign ( Role $role, string | integer $userId ) : Assignment Assigns a role to a user.
canAddChild ( Item $parent, Item $child ) : boolean Checks the possibility of adding a child to parent
createPermission ( string $name ) : Permission Creates a new Permission object.
createRole ( string $name ) : Role Creates a new Role object.
getAssignment ( string $roleName, string | integer $userId ) : null | Assignment Returns the assignment information regarding a role and a user.
getAssignments ( string | integer $userId ) : Assignment[] Returns all role assignment information for the specified user.
getChildRoles ( string $roleName ) : Role[] Returns child roles of the role specified. Depth isn't limited.
getChildren ( string $name ) : Item[] Returns the child permissions and/or roles.
getPermission ( string $name ) : null | Permission Returns the named permission.
getPermissions ( ) : Permission[] Returns all permissions in the system.
getPermissionsByRole ( string $roleName ) : Permission[] Returns all permissions that the specified role represents.
getPermissionsByUser ( string | integer $userId ) : Permission[] Returns all permissions that the user has.
getRole ( string $name ) : null | Role Returns the named role.
getRoles ( ) : Role[] Returns all roles in the system.
getRolesByUser ( string | integer $userId ) : Role[] Returns the roles that are assigned to the user via ManagerInterface::assign.
getRule ( string $name ) : null | Rule Returns the rule of the specified name.
getRules ( ) : Rule[] Returns all rules available in the system.
getUserIdsByRole ( string $roleName ) : array Returns all user IDs assigned to the role specified.
hasChild ( Item $parent, Item $child ) : boolean Returns a value indicating whether the child already exists for the parent.
remove ( Role | Permission | Rule $object ) : boolean Removes a role, permission or rule from the RBAC system.
removeAll ( ) Removes all authorization data, including roles, permissions, rules, and assignments.
removeAllAssignments ( ) Removes all role assignments.
removeAllPermissions ( ) Removes all permissions.
removeAllRoles ( ) Removes all roles.
removeAllRules ( ) Removes all rules.
removeChild ( Item $parent, Item $child ) : boolean Removes a child from its parent.
removeChildren ( Item $parent ) : boolean Removed all children form their parent.
revoke ( Role $role, string | integer $userId ) : boolean Revokes a role from a user.
revokeAll ( mixed $userId ) : boolean Revokes all roles from a user.
update ( string $name, Role | Permission | Rule $object ) : boolean Updates the specified role, permission or rule in the system.

Описание методов

add() публичный Метод

Adds a role, permission or rule to the RBAC system.
public add ( Role | Permission | Rule $object ) : boolean
$object Role | Permission | Rule
Результат boolean whether the role, permission or rule is successfully added to the system

addChild() публичный Метод

Adds an item as a child of another item.
public addChild ( Item $parent, Item $child ) : boolean
$parent Item
$child Item
Результат boolean whether the child successfully added

assign() публичный Метод

Assigns a role to a user.
public assign ( Role $role, string | integer $userId ) : Assignment
$role Role
$userId string | integer the user ID (see [[\yii\web\User::id]])
Результат Assignment the role assignment information.

canAddChild() публичный Метод

Checks the possibility of adding a child to parent
С версии: 2.0.8
public canAddChild ( Item $parent, Item $child ) : boolean
$parent Item the parent item
$child Item the child item to be added to the hierarchy
Результат boolean possibility of adding

createPermission() публичный Метод

Note that the newly created permission is not added to the RBAC system yet. You must fill in the needed data and call ManagerInterface::add to add it to the system.
public createPermission ( string $name ) : Permission
$name string the permission name
Результат Permission the new Permission object

createRole() публичный Метод

Note that the newly created role is not added to the RBAC system yet. You must fill in the needed data and call ManagerInterface::add to add it to the system.
public createRole ( string $name ) : Role
$name string the role name
Результат Role the new Role object

getAssignment() публичный Метод

Returns the assignment information regarding a role and a user.
public getAssignment ( string $roleName, string | integer $userId ) : null | Assignment
$roleName string the role name
$userId string | integer the user ID (see [[\yii\web\User::id]])
Результат null | 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 getAssignments ( string | integer $userId ) : Assignment[]
$userId string | integer the user ID (see [[\yii\web\User::id]])
Результат Assignment[] the assignments indexed by role names. An empty array will be returned if there is no role assigned to the user.

getChildRoles() публичный Метод

Returns child roles of the role specified. Depth isn't limited.
С версии: 2.0.10
public getChildRoles ( string $roleName ) : Role[]
$roleName string name of the role to file child roles for
Результат Role[] Child roles. The array is indexed by the role names. First element is an instance of the parent Role itself.

getChildren() публичный Метод

Returns the child permissions and/or roles.
public getChildren ( string $name ) : Item[]
$name string the parent name
Результат Item[] the child permissions and/or roles

getPermission() публичный Метод

Returns the named permission.
public getPermission ( string $name ) : null | Permission
$name string the permission name.
Результат null | Permission the permission corresponding to the specified name. Null is returned if no such permission.

getPermissions() публичный Метод

Returns all permissions in the system.
public getPermissions ( ) : Permission[]
Результат Permission[] all permissions in the system. The array is indexed by the permission names.

getPermissionsByRole() публичный Метод

Returns all permissions that the specified role represents.
public getPermissionsByRole ( string $roleName ) : Permission[]
$roleName string the role name
Результат Permission[] all permissions that the role represents. The array is indexed by the permission names.

getPermissionsByUser() публичный Метод

Returns all permissions that the user has.
public getPermissionsByUser ( string | integer $userId ) : Permission[]
$userId string | integer the user ID (see [[\yii\web\User::id]])
Результат Permission[] all permissions that the user has. The array is indexed by the permission names.

getRole() публичный Метод

Returns the named role.
public getRole ( string $name ) : null | Role
$name string the role name.
Результат null | Role the role corresponding to the specified name. Null is returned if no such role.

getRoles() публичный Метод

Returns all roles in the system.
public getRoles ( ) : Role[]
Результат Role[] all roles in the system. The array is indexed by the role names.

getRolesByUser() публичный Метод

Note that child roles that are not assigned directly to the user will not be returned.
public getRolesByUser ( string | integer $userId ) : Role[]
$userId string | integer the user ID (see [[\yii\web\User::id]])
Результат 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 getRule ( string $name ) : null | Rule
$name string the rule name
Результат null | 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 getRules ( ) : Rule[]
Результат Rule[] the rules indexed by the rule names

getUserIdsByRole() публичный Метод

Returns all user IDs assigned to the role specified.
С версии: 2.0.7
public getUserIdsByRole ( string $roleName ) : array
$roleName string
Результат array array of user ID strings

hasChild() публичный Метод

Returns a value indicating whether the child already exists for the parent.
public hasChild ( Item $parent, Item $child ) : boolean
$parent Item
$child Item
Результат boolean whether `$child` is already a child of `$parent`

remove() публичный Метод

Removes a role, permission or rule from the RBAC system.
public remove ( Role | Permission | Rule $object ) : boolean
$object Role | Permission | Rule
Результат boolean whether the role, permission or rule is successfully removed

removeAll() публичный Метод

Removes all authorization data, including roles, permissions, rules, and assignments.
public removeAll ( )

removeAllAssignments() публичный Метод

Removes all role assignments.

removeAllPermissions() публичный Метод

All parent child relations will be adjusted accordingly.

removeAllRoles() публичный Метод

All parent child relations will be adjusted accordingly.
public removeAllRoles ( )

removeAllRules() публичный Метод

All roles and permissions which have rules will be adjusted accordingly.
public removeAllRules ( )

removeChild() публичный Метод

Note, the child item is not deleted. Only the parent-child relationship is removed.
public removeChild ( Item $parent, Item $child ) : boolean
$parent Item
$child Item
Результат boolean whether the removal is successful

removeChildren() публичный Метод

Note, the children items are not deleted. Only the parent-child relationships are removed.
public removeChildren ( Item $parent ) : boolean
$parent Item
Результат boolean whether the removal is successful

revoke() публичный Метод

Revokes a role from a user.
public revoke ( Role $role, string | integer $userId ) : boolean
$role Role
$userId string | integer the user ID (see [[\yii\web\User::id]])
Результат boolean whether the revoking is successful

revokeAll() публичный Метод

Revokes all roles from a user.
public revokeAll ( mixed $userId ) : boolean
$userId mixed the user ID (see [[\yii\web\User::id]])
Результат boolean whether the revoking is successful

update() публичный Метод

Updates the specified role, permission or rule in the system.
public update ( string $name, Role | Permission | Rule $object ) : boolean
$name string the old name of the role, permission or rule
$object Role | Permission | Rule
Результат boolean whether the update is successful