models/Assignment.php
public function updateAssignments()
    {
        if (!$this->validate()) {
            return false;
        }

        if (!is_array($this->items)) {
            $this->items = [];
        }

        $assignedItems = $this->manager->getItemsByUser($this->user_id);
        $assignedItemsNames = array_keys($assignedItems);

        foreach (array_diff($assignedItemsNames, $this->items) as $item) {
            $this->manager->revoke($assignedItems[$item], $this->user_id);
        }

        foreach (array_diff($this->items, $assignedItemsNames) as $item) {
            $this->manager->assign($this->manager->getItem($item), $this->user_id);
        }

        $this->updated = true;

        return true;
    }
public function updateAssignments()
    {
        if (!$this->validate()) {
            return false;
        }

        if (!is_array($this->items)) {
            $this->items = [];
        }

        $assignedItems = $this->manager->getItemsByUser($this->user_id);
        $assignedItemsNames = array_keys($assignedItems);

        foreach (array_diff($assignedItemsNames, $this->items) as $item) {
            $this->manager->revoke($assignedItems[$item], $this->user_id);
        }

        foreach (array_diff($this->items, $assignedItemsNames) as $item) {
            $this->manager->assign($this->manager->getItem($item), $this->user_id);
        }

        $this->updated = true;

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