public function savePaper(Paper $publication, $path) { $jsonResponse = new JsonResponse(); if ($publication->saveFile($path)) { $statement = "INSERT INTO paper (title, filename, theme, date, year, publication_type) \r\n VALUES (:title, :filename, :subarea, :date, :year, :publication_type)"; $query = $this->session->prepare($statement); $query->bindParam(":title", $publication->title()); $query->bindParam(":filename", $publication->getFilename()); $query->bindParam(":subarea", $publication->getSubareaId()); $query->bindParam(":date", $publication->date()); $query->bindParam(":year", $publication->getYear()); $query->bindParam(":publication_type", $publication->getTypeId()); try { $query->execute(); } catch (PDOException $err) { throw new PDOException($err->getMessage()); } } else { throw new Exception("Falha ao salvar cópia do arquivo no diretório: {$path}"); } }