/**
  * Constrói uma nova Entity autor com base nos dados da view-model
  * @return \Entity\Autor
  */
 public function load_autor()
 {
     $autor = new \Entity\Autor();
     $autor->setUsuario($this->load_user());
     return $autor;
 }
Beispiel #2
0
 /**
  * adiciona o usuário já cadastrado ao papel de autor
  * @param  int $curso_id o id do curso no banco
  * @return void
  */
 public function fazerCadastroIncremental($curso_id)
 {
     $this->em->beginTransaction();
     try {
         $session_user = $this->usuario_bo->getUserSession();
         $user = $this->usuario_bo->findUserById($session_user['id']);
         $autor_orig = $this->autor_dao->find_autor_by_cpf($user->getCpf());
         if ($autor_orig != NULL) {
             $this->CI->session->set_flashdata('erro', 'Este autor já existe.');
             throw new Exception("Este autor já existe", 2);
         }
         $autor = new Entity\Autor();
         $autor->setUsuario($user);
         $this->fazerCadastroAutorAux($autor, $curso_id);
         $this->em->flush();
         $this->em->refresh($user);
         $this->usuario_bo->redefinirUserRegras($user->getIdUsuario());
         sendEmailAfterRecordUser($user->getCpf(), $user->getNome(), $user->getEmail(), "autor");
         return $user->getIdUsuario();
     } catch (Exception $e) {
         $this->em->getConnection()->rollBack();
         $this->CI->log->write_log('error', $ex->getMessage());
     }
 }