Ejemplo n.º 1
0
 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;
     }));
 }
Ejemplo n.º 2
0
 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');
 }