Ejemplo n.º 1
0
 public function save(UserRole $user)
 {
     $data = $user->getRawData();
     if ($user->getUserRoleId() > 0) {
         $id = $user->getUserRoleId();
         $this->tableGateway->update($data, array('aufri_users_role_id' => $id));
     } else {
         if (!$this->tableGateway->insert($data)) {
             throw new \Exception("Could not new row {$id}");
         }
         $id = (int) $this->tableGateway->lastInsertValue;
     }
     return $this->getOne(array('aufri_users_role_id' => $id));
 }
Ejemplo n.º 2
0
 /**
  * Function to set user roles
  * @return array $userRole array user role
  * @param array $data array containing data entered in the form
  * @param array $user array in which user data is saved
  */
 public function setUserRole($data, $user)
 {
     $userRole = new UserRole();
     $userRole->setRoleId($data['roles']);
     $userRole->setUserId($user->getId());
     return $userRole;
 }