private function createTarefaFromJsonRawData(Tarefa $tarefa = NULL) { $dataPost = $this->request->getJsonRawBody(); if (is_null($tarefa)) { $tarefa = new Tarefa(); } $tarefa->setDescricao($dataPost->descricao); $tarefa->setIdProjeto($dataPost->id_projeto->id); $tarefa->setNome($dataPost->nome); $tarefa->setTipo($dataPost->tipo->id); if (!is_numeric($tarefa->getId())) { $tarefa->setStatus(Tarefa::STATUS_NOVA); } if ($tarefa->validation() && $tarefa->save()) { $this->createTarefaItens($tarefa, $dataPost); return $tarefa; } else { $this->db->rollback(); throw new \Exception(PostResponse::createModelErrorMessages($tarefa), StatusCodes::ERRO_CLI); } }