Skip to content
Snippets Groups Projects
Verified Commit c3633a43 authored by Damien's avatar Damien
Browse files

FEAT #13671 TIME 0:35 Database creation fix + save config

parent 625dd4b5
No related branches found
No related tags found
No related merge requests found
...@@ -213,7 +213,7 @@ class InstallerController ...@@ -213,7 +213,7 @@ class InstallerController
$dsn = "pgsql:host={$body['server']};port={$body['port']};dbname={$body['name']}"; $dsn = "pgsql:host={$body['server']};port={$body['port']};dbname={$body['name']}";
$db = new \PDO($dsn, $body['user'], $body['password'], $options); $db = new \PDO($dsn, $body['user'], $body['password'], $options);
$fileContent = file_get_contents('sql/structure.sql'); $fileContent = @file_get_contents('sql/structure.sql');
if (!$fileContent) { if (!$fileContent) {
return $response->withStatus(400)->withJson(['errors' => 'Cannot read structure.sql']); return $response->withStatus(400)->withJson(['errors' => 'Cannot read structure.sql']);
} }
...@@ -223,7 +223,7 @@ class InstallerController ...@@ -223,7 +223,7 @@ class InstallerController
} }
if (!empty($body['data'])) { if (!empty($body['data'])) {
$fileContent = file_get_contents("sql/{$body['data']}.sql"); $fileContent = @file_get_contents("sql/{$body['data']}.sql");
if (!$fileContent) { if (!$fileContent) {
return $response->withStatus(400)->withJson(['errors' => "Cannot read {$body['data']}.sql"]); return $response->withStatus(400)->withJson(['errors' => "Cannot read {$body['data']}.sql"]);
} }
...@@ -233,6 +233,22 @@ class InstallerController ...@@ -233,6 +233,22 @@ class InstallerController
} }
} }
$configFile = CoreConfigModel::getJsonLoaded(['path' => "custom/{$body['customName']}/apps/maarch_entreprise/xml/config.json"]);
$configFile['database'] = [
[
"server" => $body['server'],
"port" => $body['port'],
"type" => 'POSTGRESQL',
"name" => $body['name'],
"user" => $body['user'],
"password" => $body['password']
]
];
$fp = fopen("custom/{$body['customName']}/apps/maarch_entreprise/xml/config.json", 'w');
fwrite($fp, json_encode($configFile, JSON_PRETTY_PRINT));
fclose($fp);
return $response->withStatus(204); return $response->withStatus(204);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment