예제 #1
0
 /**
  * Updates auth assignments for user.
  * @return boolean
  */
 public function updateAssignments()
 {
     if (!$this->validate()) {
         return false;
     }
     $assignedItems = $this->manager->getRolesByUser($this->user_id);
     $assignedItemsNames = array_keys($assignedItems);
     $revoke = array_diff($assignedItemsNames, $this->items);
     foreach ($revoke as $item) {
         $this->manager->revoke($assignedItems[$item], $this->user_id);
     }
     $assign = array_diff($this->items, $assignedItemsNames);
     foreach ($assign as $item) {
         $this->manager->assign($this->manager->getItem($item), $this->user_id);
     }
     $this->updated = true;
     return true;
 }