public function test_create_db() { $dm = new \DataManager(); system("rm -Rvf " . $dm->dataRoot . "/*"); $obj1 = $dm->getDefaultDocument(); $obj1->unique_identifier = "robert_blackwell"; $dm->putFile("robert_blackwell", $obj1); $obj1->unique_identifier = "blackwells"; $dm->putFile("blackwells", $obj1); }
function saveFile(Request $request) { $dataManager = new \DataManager(); $jsonString = "hello"; $jsonString = $request->getContent(); $jsonObject = json_decode($jsonString); $name = $jsonObject->document_name; $dataManager->putFile($jsonObject->document_name, $jsonObject); $doc = $dataManager->getDocument($name); if ($doc == null) { $resp = new \Symfony\Component\HttpFoundation\JsonResponse(['error' => ["errorCode" => "1002", "msg" => "document not found", "id" => $name, "data" => $jsonObject]], 200); return $resp; } return json_encode($doc); // $doc = $dataManager->saveDocument($doc); $result = ["response" => "OK", 'reqStr' => $jsonObject]; return json_encode($result); }