PHP Class yii\rbac\BaseManager

For more details and usage information on DbManager, see the guide article on security authorization.
Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\base\Component, implements yii\rbac\ManagerInterface
Show file Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$defaultRoles a list of role names that are assigned to every user automatically without calling [[assign()]].

Public Methods

Method Description
add ( $object )
createPermission ( $name )
createRole ( $name )
getPermission ( $name )
getPermissions ( )
getRole ( $name )
getRoles ( )
remove ( $object )
update ( $name, $object )

Protected Methods

Method Description
addItem ( Item $item ) : boolean Adds an auth item to the RBAC system.
addRule ( Rule $rule ) : boolean Adds a rule to the RBAC system.
executeRule ( string | integer $user, Item $item, array $params ) : boolean Executes the rule associated with the specified auth item.
getItem ( string $name ) : Item Returns the named auth item.
getItems ( integer $type ) : Item[] Returns the items of the specified type.
removeItem ( Item $item ) : boolean Removes an auth item from the RBAC system.
removeRule ( Rule $rule ) : boolean Removes a rule from the RBAC system.
updateItem ( string $name, Item $item ) : boolean Updates an auth item in the RBAC system.
updateRule ( string $name, Rule $rule ) : boolean Updates a rule to the RBAC system.

Method Details

add() public method

public add ( $object )

addItem() abstract protected method

Adds an auth item to the RBAC system.
abstract protected addItem ( Item $item ) : boolean
$item Item the item to add
return boolean whether the auth item is successfully added to the system

addRule() abstract protected method

Adds a rule to the RBAC system.
abstract protected addRule ( Rule $rule ) : boolean
$rule Rule the rule to add
return boolean whether the rule is successfully added to the system

createPermission() public method

public createPermission ( $name )

createRole() public method

public createRole ( $name )

executeRule() protected method

If the item does not specify a rule, this method will return true. Otherwise, it will return the value of [[Rule::execute()]].
protected executeRule ( string | integer $user, Item $item, array $params ) : boolean
$user string | integer the user ID. This should be either an integer or a string representing the unique identifier of a user. See [[\yii\web\User::id]].
$item Item the auth item that needs to execute its rule
$params array parameters passed to [[CheckAccessInterface::checkAccess()]] and will be passed to the rule
return boolean the return value of [[Rule::execute()]]. If the auth item does not specify a rule, true will be returned.

getItem() abstract protected method

Returns the named auth item.
abstract protected getItem ( string $name ) : Item
$name string the auth item name.
return Item the auth item corresponding to the specified name. Null is returned if no such item.

getItems() abstract protected method

Returns the items of the specified type.
abstract protected getItems ( integer $type ) : Item[]
$type integer the auth item type (either [[Item::TYPE_ROLE]] or [[Item::TYPE_PERMISSION]]
return Item[] the auth items of the specified type.

getPermission() public method

public getPermission ( $name )

getPermissions() public method

public getPermissions ( )

getRole() public method

public getRole ( $name )

getRoles() public method

public getRoles ( )

remove() public method

public remove ( $object )

removeItem() abstract protected method

Removes an auth item from the RBAC system.
abstract protected removeItem ( Item $item ) : boolean
$item Item the item to remove
return boolean whether the role or permission is successfully removed

removeRule() abstract protected method

Removes a rule from the RBAC system.
abstract protected removeRule ( Rule $rule ) : boolean
$rule Rule the rule to remove
return boolean whether the rule is successfully removed

update() public method

public update ( $name, $object )

updateItem() abstract protected method

Updates an auth item in the RBAC system.
abstract protected updateItem ( string $name, Item $item ) : boolean
$name string the name of the item being updated
$item Item the updated item
return boolean whether the auth item is successfully updated

updateRule() abstract protected method

Updates a rule to the RBAC system.
abstract protected updateRule ( string $name, Rule $rule ) : boolean
$name string the name of the rule being updated
$rule Rule the updated rule
return boolean whether the rule is successfully updated

Property Details

$defaultRoles public property

a list of role names that are assigned to every user automatically without calling [[assign()]].
public $defaultRoles