/** * @expectedException Application\Exceptions\ValidateException */ public function testUpdateNonEditableOrganizationId() { // Persist user $this->_user->save(); $this->_user->setOrganizationId('noexists-123123123'); $this->_service->update($this->_user); }
public function putAction() { $data = $this->_helper->requestData(true, false); $user = $this->_getUser(); $this->_helper->allowed('update', $user); if (!empty($data)) { $data = $this->_mapToModel($data, false); } // Filter data $data = $this->_helper->filter($data)->blacklist(array('id', 'password', 'status')); $newUser = new UserModel($data); $this->_helper->filterNotAllowedFields('update_field', $user, $newUser); // Modify the current details with the new data $user->importData($newUser->exportData()); $this->_validateUserData($user); $this->_userSrv->update($user); $this->getResponse()->setHttpResponseCode(204); $this->_helper->viewRenderer->setNoRender(TRUE); }
/** * Update an user identified by its Id */ public function putAction() { $data = $this->_helper->requestData(true); // Try to load the chosen user $id = $this->getRequest()->getParam('id'); $user = $this->_userSrv->load($id); if (empty($user)) { throw new NotFoundException('User ' . $id . ' not found', 404); } // Check permissions $this->_helper->allowed('update', $user); // Filter data $data = $this->_helper->filter($data)->blacklist(array('id', 'password', 'status')); $userClass = get_class($user); $newUser = new $userClass($data); $this->_helper->filterNotAllowedFields('update_field', $user, $newUser); // Modify the current details with the new data $user->importData($newUser->exportData()); // Perform the update $this->_userSrv->update($user); $this->view->data = $user->getId(); }