Class yeesoft\models\Role

Inheritanceyeesoft\models\Role » yeesoft\models\AbstractItem » yeesoft\db\ActiveRecord » yii\db\ActiveRecord

Public Methods

Hide inherited methods

MethodDescriptionDefined By
addChildren() Helper for adding children to role or permission yeesoft\models\AbstractItem
afterDelete() Invalidate permissions if some item is deleted yeesoft\models\AbstractItem
assignRoutesViaPermission() Assign route to role via permission and create permission or route if it don't exists Helper mainly for migrations yeesoft\models\Role
attributeLabels() yeesoft\models\AbstractItem
beforeSave() Ensure type of item yeesoft\models\AbstractItem
behaviors() yeesoft\models\AbstractItem
create() Useful helper for migrations and other stuff If description is null than it will be transformed like "editUserEmail" => "Edit user email" yeesoft\models\AbstractItem
deleteIfExists() yeesoft\models\AbstractItem
find() yeesoft\models\AbstractItem
getAvailableRoles() Return only roles, that are assigned to the current user. yeesoft\models\Role
getGroup() yeesoft\models\AbstractItem
getPermissionsByRole() Get permissions assigned to this role or its children yeesoft\models\Role
getUserRoles() yeesoft\models\Role
isMultilingual() Returns TRUE if model support multilingual behavior. yeesoft\db\ActiveRecord
removeChildren() yeesoft\models\AbstractItem
rules() yeesoft\models\AbstractItem
tableName() yeesoft\models\AbstractItem
validateUniqueName() Default unique validator search only within specific class (Role, Route or Permission) because of the overwritten find() method yeesoft\models\AbstractItem

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
ITEM_TYPE self::TYPE_ROLE yeesoft\models\Role
TYPE_PERMISSION 2 yeesoft\models\AbstractItem
TYPE_ROLE 1 yeesoft\models\AbstractItem
TYPE_ROUTE 3 yeesoft\models\AbstractItem

Method Details

assignRoutesViaPermission() public static method

Assign route to role via permission and create permission or route if it don't exists Helper mainly for migrations

public static true|static|string assignRoutesViaPermission ( $roleName, $permissionName, $routes, $permissionDescription null, $groupCode null )
$roleName string
$permissionName string
$routes array
$permissionDescription null|string
$groupCode null|string
throws InvalidArgumentException
getAvailableRoles() public static method

Return only roles, that are assigned to the current user.

Return all if superadmin Useful for forms where user can give roles to another users, but we restrict him only with roles he possess

public static static getAvailableRoles ( $showAll false, $asArray false )
$showAll bool
$asArray bool
getPermissionsByRole() public static method

Get permissions assigned to this role or its children

public static array|yeesoft\models\Permission[] getPermissionsByRole ( $roleName, $asArray true )
$roleName string
$asArray bool
getUserRoles() public static method

public static array|\yii\rbac\Role getUserRoles ( $userId )
$userId int