yii\rbac\ManagerInterface::getAssignments PHP Method

getAssignments() public method

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]])
return Assignment[] the assignments indexed by role names. An empty array will be returned if there is no role assigned to the user.
    public function getAssignments($userId);

Usage Example

 public function testAssignmentsToIntegerId()
 {
     $this->prepareData();
     $reader = $this->auth->getRole('reader');
     $author = $this->auth->getRole('author');
     $this->auth->assign($reader, 42);
     $this->auth->assign($author, 1337);
     $this->auth->assign($reader, 1337);
     $this->auth = $this->createManager();
     $this->assertEquals(0, count($this->auth->getAssignments(0)));
     $this->assertEquals(1, count($this->auth->getAssignments(42)));
     $this->assertEquals(2, count($this->auth->getAssignments(1337)));
 }
All Usage Examples Of yii\rbac\ManagerInterface::getAssignments