mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Refactor Configuration
This commit is contained in:
@@ -283,7 +283,7 @@ class Core extends \Pimple
|
|||||||
/**
|
/**
|
||||||
* Getter
|
* Getter
|
||||||
*
|
*
|
||||||
* @return Core\Configuration
|
* @return \Alchemy\Phrasea\Core\Configuration
|
||||||
*/
|
*/
|
||||||
public function getConfiguration()
|
public function getConfiguration()
|
||||||
{
|
{
|
||||||
|
@@ -50,8 +50,15 @@ class Configuration
|
|||||||
{
|
{
|
||||||
$this->specifications = $specifications;
|
$this->specifications = $specifications;
|
||||||
|
|
||||||
$configurations = $this->specifications->getConfigurations();
|
if ($specifications->isSetup())
|
||||||
$environment = $environment ? : $configurations[self::KEYWORD_ENV];
|
{
|
||||||
|
$configurations = $this->specifications->getConfigurations();
|
||||||
|
$environment = $environment ? : $configurations[self::KEYWORD_ENV];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$environment = null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->setEnvironnement($environment);
|
$this->setEnvironnement($environment);
|
||||||
|
|
||||||
|
@@ -102,18 +102,21 @@ class ApplicationSpecification implements Specification
|
|||||||
|
|
||||||
public function initialize()
|
public function initialize()
|
||||||
{
|
{
|
||||||
touch($this->getConnexionsPathFile());
|
$this->delete();
|
||||||
touch($this->getConfigurationsPathFile());
|
|
||||||
touch($this->getServicesPathFile());
|
|
||||||
|
|
||||||
copy(
|
copy(
|
||||||
$this->getRealRootPath() . "/config/config.sample.yml"
|
$this->getRealRootPath() . "/config/connexions.sample.yml"
|
||||||
, $this->getRealRootPath() . "/config/config.yml"
|
, $this->getConnexionsPathFile()
|
||||||
);
|
);
|
||||||
|
|
||||||
copy(
|
copy(
|
||||||
$this->getRealRootPath() . "/config/services.sample.yml"
|
$this->getRealRootPath() . "/config/services.sample.yml"
|
||||||
, $this->getRealRootPath() . "/config/services.yml"
|
, $this->getServicesPathFile()
|
||||||
|
);
|
||||||
|
|
||||||
|
copy(
|
||||||
|
$this->getRealRootPath() . "/config/config.sample.yml"
|
||||||
|
, $this->getConfigurationsPathFile()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (function_exists('chmod'))
|
if (function_exists('chmod'))
|
||||||
|
@@ -37,6 +37,7 @@ class module_console_systemUpgrade extends Command
|
|||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output)
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$Core = \bootstrap::getCore();
|
||||||
if (!setup::is_installed())
|
if (!setup::is_installed())
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -53,29 +54,40 @@ class module_console_systemUpgrade extends Command
|
|||||||
if ($continue == 'y')
|
if ($continue == 'y')
|
||||||
{
|
{
|
||||||
|
|
||||||
$file = __DIR__ . "/../../../../config/config.sample.yml";
|
try
|
||||||
$file1 = __DIR__ . "/../../../../config/config.yml";
|
|
||||||
|
|
||||||
if (!copy($file, $file1))
|
|
||||||
{
|
{
|
||||||
throw new \Exception(sprintf("Unable to copy %s", $file1));
|
$Core->getConfiguration()->initialize();
|
||||||
|
|
||||||
|
$retrieve_old_credentials = function()
|
||||||
|
{
|
||||||
|
require __DIR__ . '/../../../../config/connexion.inc';
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'hostname' => $hostname,
|
||||||
|
'port' => $port,
|
||||||
|
'user' => $user,
|
||||||
|
'password' => $password,
|
||||||
|
'dbname' => $dbname,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
$credentials = $retrieve_old_credentials();
|
||||||
|
|
||||||
|
$connexions = $Core->getConfiguration()->getConnexions();
|
||||||
|
|
||||||
|
foreach ($credentials as $key => $value)
|
||||||
|
{
|
||||||
|
$key = $key == 'hostname' ? 'host' : $key;
|
||||||
|
$connexions['main_connexion'][$key] = (string) $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$Core->getConfiguration()->setConnexions($connexions);
|
||||||
|
$Core->getConfiguration()->setEnvironnement('prod');
|
||||||
}
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
$conn = \connection::getPDOConnection();
|
|
||||||
|
|
||||||
$credentials = $conn->get_credentials();
|
|
||||||
|
|
||||||
$configuration = \Alchemy\Phrasea\Core\Configuration::build();
|
|
||||||
|
|
||||||
$connexionINI = array();
|
|
||||||
|
|
||||||
foreach ($credentials as $key => $value)
|
|
||||||
{
|
{
|
||||||
$key = $key == 'hostname' ? 'host' : $key;
|
|
||||||
$connexionINI[$key] = (string) $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
$configuration->setAllDatabaseConnexion($connexionINI);
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -99,8 +111,9 @@ class module_console_systemUpgrade extends Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$Core = \bootstrap::getCore();
|
||||||
$output->write('<info>Upgrading...</info>', true);
|
$output->write('<info>Upgrading...</info>', true);
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance($Core);
|
||||||
|
|
||||||
if (count(User_Adapter::get_wrong_email_users($appbox)) > 0)
|
if (count(User_Adapter::get_wrong_email_users($appbox)) > 0)
|
||||||
{
|
{
|
||||||
@@ -108,10 +121,11 @@ class module_console_systemUpgrade extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$upgrader = new Setup_Upgrade($appbox);
|
$upgrader = new Setup_Upgrade($appbox);
|
||||||
$advices = $appbox->forceUpgrade($upgrader);
|
$advices = $appbox->forceUpgrade($upgrader);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
|
||||||
$output->writeln(sprintf('<error>An error occured while upgrading : %s </error>', $e->getMessage()));
|
$output->writeln(sprintf('<error>An error occured while upgrading : %s </error>', $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user