getRoles() public method

Returns all roles in the system.
public getRoles ( ) : Role[]
return Role[] all roles in the system. The array is indexed by the role names.
Esempio n. 1
0
 /**
  * Get all available and assigned roles and permissions
  *
  * @return array
  */
 public function getItems()
 {
     $available = [];
     $assigned = [];
     foreach (array_keys($this->manager->getRoles()) as $name) {
         $available[$name] = 'role';
     }
     foreach (array_keys($this->manager->getPermissions()) as $name) {
         if ($name[0] != '/') {
             $available[$name] = 'permission';
         }
     }
     foreach ($this->manager->getAssignments($this->userId) as $item) {
         $assigned[$item->roleName] = $available[$item->roleName];
         unset($available[$item->roleName]);
     }
     return ['available' => $available, 'assigned' => $assigned];
 }
Esempio n. 2
0
 /**
  * Get all available and assigned roles, permission and routes
  *
  * @return array
  */
 public function getItems()
 {
     $available = [];
     $assigned = [];
     if ($this->type == Item::TYPE_ROLE) {
         foreach (array_keys($this->manager->getRoles()) as $name) {
             $available[$name] = 'role';
         }
     }
     foreach (array_keys($this->manager->getPermissions()) as $name) {
         $available[$name] = $name[0] == '/' ? 'route' : 'permission';
     }
     foreach ($this->manager->getChildren($this->_item->name) as $item) {
         $assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' ? 'route' : 'permission');
         unset($available[$item->name]);
     }
     unset($available[$this->name]);
     return ['available' => $available, 'assigned' => $assigned];
 }
Esempio n. 3
0
 public function actionIndex()
 {
     $rs = $this->auth->getRoles();
     $dataProvider = new ArrayDataProvider(['allModels' => $rs]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }