Skip to content
Snippets Groups Projects
Commit 1106b1eb authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

FEAT #5938

parent c29d7d8e
No related branches found
No related tags found
No related merge requests found
......@@ -34,12 +34,37 @@ class ResController
{
public function create(RequestInterface $request, ResponseInterface $response, $aArgs)
{
if(empty($aArgs)){
if(empty($aArgs)) {
$aArgs = $request->getQueryParams();
$aArgs['data'] = json_decode($aArgs['data']);
$aArgs['data'] = $this->object2array($aArgs['data']);
//FIX pb if data has parent
if (isset($aArgs['data']['data'])) {
$aArgs['data'] = $aArgs['data']['data'];
}
}
//*****************************************************************************************
//LOG ONLY LOG FOR DEBUG
// $file = fopen('storeResourceLogs.log', a);
// fwrite($file, '[' . date('Y-m-d H:i:s') . '] new request' . PHP_EOL);
// foreach ($aArgs as $key => $value) {
// if ($key <> 'encodedFile') {
// fwrite($file, '[' . date('Y-m-d H:i:s') . '] ' . $key . ' : ' . $value . PHP_EOL);
// }
// }
// fclose($file);
// ob_flush();
// ob_start();
// print_r($aArgs['data']);
// file_put_contents("storeResourceLogs.log", ob_get_flush());
//END LOG FOR DEBUG ONLY
//*****************************************************************************************
$return = $this->storeResource($aArgs);
if ($return['errors']) {
......@@ -49,8 +74,11 @@ class ResController
['errors' => _NOT_CREATE . ' ' . $return['errors']]
);
}
//standardize ws response for MaarchCapture
$wsReturn['resId'] = $return[0];
return $response->withJson($return);
return $response->withJson($wsReturn);
}
public function delete(RequestInterface $request, ResponseInterface $response, $aArgs)
......@@ -158,7 +186,8 @@ class ResController
$returnCode = 0;
//copy sended file on tmp
$fileContent = base64_decode($encodedFile);
//$fileContent = base64_decode($encodedFile);
$fileContent = base64_decode(str_replace(array('-', '_'), array('+', '/'), $encodedFile));
$random = rand();
$fileName = 'tmp_file_' . $random . '.' . $fileFormat;
$Fnm = CoreConfigModel::getTmpPath() . $fileName;
......
......@@ -227,7 +227,7 @@ class ResControllerTest extends TestCase
$response = new \Slim\Http\Response();
$response = $action->create($request, $response, $aArgs);
//print_r($response);exit;
$this->assertGreaterThan(1, json_decode($response->getBody())[0]);
$this->assertGreaterThan(1, json_decode($response->getBody())->resId);
}
public function testDeleteRes()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment