mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
copy the new config .yml file with user settings
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
@@ -39,41 +40,51 @@ class module_console_systemUpgrade extends Command
|
|||||||
if (!setup::is_installed())
|
if (!setup::is_installed())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (file_exists(__DIR__ . "/../../../../config/connexion.inc")
|
$output->writeln('This version of Phraseanet requires a config/config.inc');
|
||||||
&& !file_exists(__DIR__ . "/../../../../config/config.inc")
|
$output->writeln('Would you like it to be created based on your settings ?');
|
||||||
&& file_exists(__DIR__ . "/../../../../config/_GV.php"))
|
|
||||||
|
$dialog = $this->getHelperSet()->get('dialog');
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$continue = mb_strtolower($dialog->ask($output, '<question>' . _('Create automatically') . ' (Y/n)</question>', 'y'));
|
||||||
|
}
|
||||||
|
while (!in_array($continue, array('y', 'n')));
|
||||||
|
|
||||||
|
if ($continue == 'y')
|
||||||
{
|
{
|
||||||
|
|
||||||
$output->writeln('This version of Phraseanet requires a config/config.inc');
|
$file = __DIR__ . "/../../config/config.sample.yml";
|
||||||
$output->writeln('Would you like it to be created based on your settings ?');
|
$file1 = __DIR__ . "/../../config/config.yml";
|
||||||
|
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
if (!copy($file, $file1))
|
||||||
do
|
|
||||||
{
|
{
|
||||||
$continue = mb_strtolower($dialog->ask($output, '<question>' . _('Create automatically') . ' (Y/n)</question>', 'y'));
|
throw new \Exception(sprintf("Unable to copy %s", $file1));
|
||||||
}
|
|
||||||
while (!in_array($continue, array('y', 'n')));
|
|
||||||
|
|
||||||
if ($continue == 'y')
|
|
||||||
{
|
|
||||||
require __DIR__ . "/../../../../config/_GV.php";
|
|
||||||
|
|
||||||
$datas = '<?php'."\n"
|
|
||||||
.'$servername = "'.GV_ServerName.'";'."\n"
|
|
||||||
.'$maintenance=false;'."\n"
|
|
||||||
.'$debug=false;'."\n"
|
|
||||||
.'$debug=true;'."\n"
|
|
||||||
.'';
|
|
||||||
|
|
||||||
file_put_contents(__DIR__ . "/../../../../config/config.inc", $datas);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new RuntimeException('Phraseanet is not set up');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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
|
||||||
|
{
|
||||||
|
throw new RuntimeException('Phraseanet is not set up');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../lib/bootstrap.php';
|
require_once __DIR__ . '/../../../../lib/bootstrap.php';
|
||||||
|
Reference in New Issue
Block a user