copy the new config .yml file with user settings

This commit is contained in:
Nicolas Le Goff
2012-01-03 14:58:44 +01:00
parent c4de980ba7
commit 0812cb0a9b

View File

@@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Phraseanet * This file is part of Phraseanet
* *
@@ -39,11 +40,6 @@ class module_console_systemUpgrade extends Command
if (!setup::is_installed()) if (!setup::is_installed())
{ {
if (file_exists(__DIR__ . "/../../../../config/connexion.inc")
&& !file_exists(__DIR__ . "/../../../../config/config.inc")
&& file_exists(__DIR__ . "/../../../../config/_GV.php"))
{
$output->writeln('This version of Phraseanet requires a config/config.inc'); $output->writeln('This version of Phraseanet requires a config/config.inc');
$output->writeln('Would you like it to be created based on your settings ?'); $output->writeln('Would you like it to be created based on your settings ?');
@@ -56,24 +52,39 @@ class module_console_systemUpgrade extends Command
if ($continue == 'y') if ($continue == 'y')
{ {
require __DIR__ . "/../../../../config/_GV.php";
$datas = '<?php'."\n" $file = __DIR__ . "/../../config/config.sample.yml";
.'$servername = "'.GV_ServerName.'";'."\n" $file1 = __DIR__ . "/../../config/config.yml";
.'$maintenance=false;'."\n"
.'$debug=false;'."\n"
.'$debug=true;'."\n"
.'';
file_put_contents(__DIR__ . "/../../../../config/config.inc", $datas); if (!copy($file, $file1))
{
throw new \Exception(sprintf("Unable to copy %s", $file1));
}
$conn = \connection::getPDOConnection();
$credentials = $conn->get_credentials();
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
new \Alchemy\Phrasea\Core\Configuration\Application(),
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
);
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
$connexionINI = array();
foreach ($credentials as $key => $value)
{
$key = $key == 'hostname' ? 'host' : $key;
$connexionINI[$key] = (string) $value;
}
$configuration->setAllDatabaseConnexion($connexionINI);
} }
else else
{ {
throw new RuntimeException('Phraseanet is not set up'); throw new RuntimeException('Phraseanet is not set up');
} }
}
} }
require_once __DIR__ . '/../../../../lib/bootstrap.php'; require_once __DIR__ . '/../../../../lib/bootstrap.php';