PHP Class dektrium\rbac\migrations\Migration

Author: Dmitry Erofeev ([email protected])
Inheritance: extends yii\base\Component, implements yii\db\MigrationInterface
Datei anzeigen Open project: dektrium/yii2-rbac

Public Properties

Property Type Description
$authManager The auth manager component ID that this migration should work with.

Public Methods

Method Description
down ( ) : boolean This method contains the logic to be executed when removing this migration.
init ( ) Initializes the migration.
safeDown ( ) : boolean This method contains the logic to be executed when removing this migration.
safeUp ( ) : boolean This method contains the logic to be executed when applying this migration.
up ( ) : boolean This method contains the logic to be executed when applying this migration.

Protected Methods

Method Description
addChild ( Item | string $parent, Item | string $child ) Adds child.
assign ( string | Role $role, string | integer $userId ) Assigns a role to a user.
createPermission ( string $name, string $description = '', string | null $ruleName = null, mixed | null $data = null ) : Permission Creates new permission.
createRole ( string $name, string $description = '', string | null $ruleName = null, mixed | null $data = null ) : Role Creates new role.
createRule ( string $ruleName, string | array $definition ) : Rule Creates new rule.
findItem ( string $name ) : Permission | Role | null Finds either role or permission or throws an exception if it is not found.
findPermission ( string $name ) : Permission | null Finds the permission or throws an exception if it is not found.
findRole ( string $name ) : Role | null Finds the role or throws an exception if it is not found.
removeItem ( string | Item $item ) Removes auth item.
updatePermission ( string | Permission $permission, string $description = '', string $ruleName = null, mixed $data = null ) : Permission Updates permission.
updateRole ( string | Role $role, string $description = '', string $ruleName = null, mixed $data = null ) : Role Updates role.
updateRule ( string $ruleName, string $className ) : Rule Updates rule.

Method Details

addChild() protected method

Adds child.
protected addChild ( Item | string $parent, Item | string $child )
$parent yii\rbac\Item | string Either name or Item instance which is parent
$child yii\rbac\Item | string Either name or Item instance which is child

assign() protected method

Assigns a role to a user.
protected assign ( string | Role $role, string | integer $userId )
$role string | yii\rbac\Role
$userId string | integer

createPermission() protected method

Creates new permission.
protected createPermission ( string $name, string $description = '', string | null $ruleName = null, mixed | null $data = null ) : Permission
$name string The name of the permission
$description string The description of the permission
$ruleName string | null The rule associated with the permission
$data mixed | null The additional data associated with the permission
return yii\rbac\Permission

createRole() protected method

Creates new role.
protected createRole ( string $name, string $description = '', string | null $ruleName = null, mixed | null $data = null ) : Role
$name string The name of the role
$description string The description of the role
$ruleName string | null The rule associated with the role
$data mixed | null The additional data associated with the role
return yii\rbac\Role

createRule() protected method

Creates new rule.
protected createRule ( string $ruleName, string | array $definition ) : Rule
$ruleName string The name of the rule
$definition string | array The class of the rule
return yii\rbac\Rule

down() public method

The default implementation throws an exception indicating the migration cannot be removed. Child classes should not override this method, but use safeDown instead.
public down ( ) : boolean
return boolean return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

findItem() protected method

Finds either role or permission or throws an exception if it is not found.
protected findItem ( string $name ) : Permission | Role | null
$name string
return yii\rbac\Permission | yii\rbac\Role | null

findPermission() protected method

Finds the permission or throws an exception if it is not found.
protected findPermission ( string $name ) : Permission | null
$name string
return yii\rbac\Permission | null

findRole() protected method

Finds the role or throws an exception if it is not found.
protected findRole ( string $name ) : Role | null
$name string
return yii\rbac\Role | null

init() public method

This method will set [[authManager]] to be the 'authManager' application component, if it is null.
public init ( )

removeItem() protected method

Removes auth item.
protected removeItem ( string | Item $item )
$item string | yii\rbac\Item Either item name or item instance to be removed.

safeDown() public method

This method contains the logic to be executed when removing this migration.
public safeDown ( ) : boolean
return boolean return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

safeUp() public method

This method contains the logic to be executed when applying this migration.
public safeUp ( ) : boolean
return boolean return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

up() public method

Child classes should not override this method, but use safeUp instead.
public up ( ) : boolean
return boolean return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

updatePermission() protected method

Updates permission.
protected updatePermission ( string | Permission $permission, string $description = '', string $ruleName = null, mixed $data = null ) : Permission
$permission string | yii\rbac\Permission
$description string
$ruleName string
$data mixed
return yii\rbac\Permission

updateRole() protected method

Updates role.
protected updateRole ( string | Role $role, string $description = '', string $ruleName = null, mixed $data = null ) : Role
$role string | yii\rbac\Role
$description string
$ruleName string
$data mixed
return yii\rbac\Role

updateRule() protected method

Updates rule.
protected updateRule ( string $ruleName, string $className ) : Rule
$ruleName string
$className string
return yii\rbac\Rule

Property Details

$authManager public_oe property

The auth manager component ID that this migration should work with.
public $authManager