public function save($data) { $data['user_id'] = $this->_userIdentity->id; $userProfile = $this->get(); if (!$userProfile) { //Se o profile não existe, será criado $userProfile = new Nidorx_Model_Vo_User_Profile($data); } else { // O profile já existe, será populado apenas $userProfile->populate($data); } return $this->_daoUserProfile->save($userProfile); }
/** * Cria um novo usuário no mongo * * @param Nidorx_Model_Vo_User $voUserProfile * @return Nidorx_Bridge_Output */ public function save(Nidorx_Model_Vo_User_Profile &$voUserProfile) { $profileBd = null; if ($voUserProfile->id) { //Se já existir o id, está editando $profileBd = $this->getByUserId($voUserProfile->userId, false); $profileBd->setFromArray($voUserProfile->toArray(true, true)); } else { //Está criando o usuaŕio $profileBd = $this->createRow($voUserProfile->toArray(true, true)); } //Finalmente salva os dados if ($profileBd->save()) { $voUser->id = $profileBd->id; return true; }; return false; }