yii\rbac\ManagerInterface::getRolesByUser PHP Method

getRolesByUser() public method

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]])
return Role[] all roles directly assigned to the user. The array is indexed by the role names.
    public function getRolesByUser($userId);

Usage Example

Beispiel #1
0
 public function testGetRolesByUser()
 {
     $this->prepareData();
     $roles = $this->auth->getRolesByUser('reader A');
     $this->assertTrue(reset($roles) instanceof Role);
     $this->assertEquals($roles['reader']->name, 'reader');
 }
All Usage Examples Of yii\rbac\ManagerInterface::getRolesByUser