public function getServiceConfig() { return array('invokables' => array('api_user_service' => UserService::class, 'api_post_service' => PostService::class, 'api_comment_service' => CommentService::class), 'factories' => array('api_user_entity' => function ($sm) { $entity = new User(); $entity->setDbAdaptor($sm->get('Zend\\Db\\Adapter\\Adapter')); return $entity; })); }
public function update(\Api\Entity\User $user) { $hydrator = $this->getHydrator(); $postData = array('display_name' => $user->getDisplayName(), 'password' => $user->getPassword()); $update = new Update('user'); $update->set($postData); $update->where(array('user_id = ?' => $user->getUserId())); $sql = new Sql($this->getAdaptor()); $statement = $sql->prepareStatementForSqlObject($update); $result = $statement->execute(); if ($result instanceof ResultInterface) { if ($pk = $result->getGeneratedValue()) { $user->setUserId($pk); } return $this->getUser($user->getUserId()); } throw new \Exception('something went wrong.Please try again later'); }