mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Add init command
This commit is contained in:
@@ -228,10 +228,8 @@ class Application extends SilexApplication
|
||||
}
|
||||
}
|
||||
|
||||
$imagineDriver = $app['phraseanet.registry']->get('GV_imagine_driver');
|
||||
|
||||
$configuration['ffmpeg.threads'] = $app['phraseanet.registry']->get('GV_ffmpeg_threads');
|
||||
$configuration['imagine.driver'] = $imagineDriver ?: null;
|
||||
$configuration['ffmpeg.threads'] = $app['phraseanet.registry']->get('GV_ffmpeg_threads') ?: null;
|
||||
$configuration['imagine.driver'] = $app['phraseanet.registry']->get('GV_imagine_driver') ?: null;
|
||||
|
||||
return $configuration;
|
||||
});
|
||||
|
||||
136
lib/Alchemy/Phrasea/Command/Developer/IniReset.php
Normal file
136
lib/Alchemy/Phrasea/Command/Developer/IniReset.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Developer;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class IniReset extends Command
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('ini:reset');
|
||||
|
||||
$this->setDescription('Reset environment')
|
||||
->addOption('name', null, InputOption::VALUE_OPTIONAL, 'Databox name to reset, in case of multiple databox are mounted', null)
|
||||
->addOption('dependencies', null, InputOption::VALUE_NONE, 'Fetch dependencies', null)
|
||||
->addOption('v3.1', null, InputOption::VALUE_NONE, 'Reset with v3.1 fixtures', null)
|
||||
->addOption('uninstall', null, InputOption::VALUE_NONE, 'Uninstall Phraseanet', null);
|
||||
;
|
||||
}
|
||||
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (!$this->container['phraseanet.configuration']->isSetup()) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'Phraseanet is not setup. You can run <info>bin/setup system::install</info> command to install Phraseanet.'
|
||||
));
|
||||
}
|
||||
|
||||
// get dbs
|
||||
$conf = $this->container['phraseanet.configuration']->getConfig();
|
||||
$dbs = array('ab' => $conf['main']['database']['dbname'], 'dbs' => array(), 'setup_dbs' => array());
|
||||
foreach($this->container['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||
$dbs['dbs'][] = $databox->get_dbname();
|
||||
}
|
||||
|
||||
//uninstall
|
||||
if ($input->getOption('uninstall')) {
|
||||
$command = $this->getApplication()->find('system:uninstall');
|
||||
|
||||
$output->writeln('Uninstalling...<info>OK</info>');
|
||||
$input = new ArrayInput(array(
|
||||
'command' => 'system:uninstall'
|
||||
));
|
||||
$command->run($input, $output);
|
||||
}
|
||||
|
||||
//run composer
|
||||
//run bower
|
||||
if ($input->getOption('dependencies')) {
|
||||
$command = $this->getApplication()->find('dependencies:composer');
|
||||
|
||||
$input = new ArrayInput(array(
|
||||
'command' => 'dependencies:composer'
|
||||
));
|
||||
$command->run($input, $output);
|
||||
|
||||
$command = $this->getApplication()->find('dependencies:bower');
|
||||
|
||||
$input = new ArrayInput(array(
|
||||
'command' => 'dependencies:bower'
|
||||
));
|
||||
$command->run($input, $output);
|
||||
}
|
||||
|
||||
if (count($dbs['dbs']) > 1) {
|
||||
if ($input->getOption('name')) {
|
||||
$dbName = $input->getOption('name');
|
||||
} else {
|
||||
$dialog = $this->getHelperSet()->get('dialog');
|
||||
$dbName = $dialog->ask(
|
||||
$output,
|
||||
_('Please enter the databox name to reset')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$dbName = current($dbs['dbs']);
|
||||
}
|
||||
|
||||
$schema = $this->container['EM']->getConnection()->getSchemaManager();
|
||||
$output->writeln('Creating database "'.$dbs['ab'].'"...<info>OK</info>');
|
||||
$schema->dropAndCreateDatabase($dbs['ab']);
|
||||
$output->writeln('Creating database "'.$dbName.'"...<info>OK</info>');
|
||||
$schema->dropAndCreateDatabase($dbName);
|
||||
|
||||
// inject v3.1 fixtures
|
||||
if ($input->getOption('v3.1')) {
|
||||
$this->container['filesystem']->copy($this->container['root.path'].'/hudson/connexion.inc', $this->container['root.path'].'/config/connexion.inc');
|
||||
$this->container['filesystem']->copy($this->container['root.path'].'/hudson/_GV.php', $this->container['root.path'].'/config/_GV.php');
|
||||
|
||||
$command = $this->getApplication()->find('dbal:import');
|
||||
|
||||
$content = file_get_contents($this->container['root.path'] . '/hudson/fixtures.sql');
|
||||
$content = str_replace('ab_test', $dbs['ab'], $content);
|
||||
$content = str_replace('db_test', $dbName, $content);
|
||||
|
||||
$tmpFile = tempnam(sys_get_temp_dir(), 'fixtures-v3.1-');
|
||||
$this->container['filesystem']->dumpFile($tmpFile, $content);
|
||||
|
||||
$input = new ArrayInput(array(
|
||||
'command' => 'dbal:import',
|
||||
'file' => $tmpFile
|
||||
));
|
||||
|
||||
$verbosity = $output->getVerbosity();
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
||||
$command->run($input, $output);
|
||||
$output->setVerbosity($verbosity);
|
||||
$output->writeln('Importing Phraseanet v3.1 fixtures...<info>OK</info>');
|
||||
}
|
||||
|
||||
// create setup dbs
|
||||
$command = $this->getApplication()->find('ini:setup-tests-dbs');
|
||||
$input = new ArrayInput(array(
|
||||
'command' => 'ini:setup-tests-dbs'
|
||||
));
|
||||
$command->run($input, $output);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
66
lib/Alchemy/Phrasea/Command/Developer/SetupTestsDbs.php
Normal file
66
lib/Alchemy/Phrasea/Command/Developer/SetupTestsDbs.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Developer;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class SetupTestsDbs extends Command
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('ini:setup-tests-dbs');
|
||||
|
||||
$this->setDescription('Setup dbs for tests environment');
|
||||
}
|
||||
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (!$this->container['phraseanet.configuration']->isSetup()) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'Phraseanet is not setup. You can run <info>bin/setup system::install</info> command to install Phraseanet.'
|
||||
));
|
||||
}
|
||||
|
||||
$settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../hudson/InstallDBs.yml'));
|
||||
|
||||
$dbs = array();
|
||||
|
||||
$dbs[] = $settings['database']['ab_name'];
|
||||
$dbs[] = $settings['database']['db_name'];
|
||||
|
||||
$schema = $this->container['EM']->getConnection()->getSchemaManager();
|
||||
|
||||
foreach($dbs as $name) {
|
||||
$output->writeln('Creating database "'.$name.'"...<info>OK</info>');
|
||||
$schema->dropAndCreateDatabase($name);
|
||||
}
|
||||
|
||||
$this->container['EM']->getConnection()->executeUpdate('
|
||||
GRANT ALL PRIVILEGES ON '.$settings['database']['ab_name'].'.* TO \''.$settings['database']['user'].'\'@\''.$settings['database']['host'].'\' IDENTIFIED BY \''.$settings['database']['password'].'\' WITH GRANT OPTION
|
||||
');
|
||||
|
||||
$this->container['EM']->getConnection()->executeUpdate('
|
||||
GRANT ALL PRIVILEGES ON '.$settings['database']['db_name'].'.* TO \''.$settings['database']['user'].'\'@\''.$settings['database']['host'].'\' IDENTIFIED BY \''.$settings['database']['password'].'\' WITH GRANT OPTION
|
||||
');
|
||||
|
||||
$this->container['EM']->getConnection()->executeUpdate('SET @@global.sql_mode= ""');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ class LocaleServiceProvider implements ServiceProviderInterface
|
||||
$app['locale'] = $app->share(function (Application $app) {
|
||||
return $app['phraseanet.registry']->get('GV_default_lng', 'en_GB');
|
||||
});
|
||||
|
||||
$app['locale.I18n'] = $app->share(function (Application $app) {
|
||||
$data = explode('_', $app['locale']);
|
||||
|
||||
|
||||
@@ -9,14 +9,8 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo write tests
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Core\Version;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -65,7 +59,7 @@ class module_console_systemUpgrade extends Command
|
||||
}
|
||||
|
||||
if ($continue == 'y') {
|
||||
$output->write('<info>Upgrading...</info>', true);
|
||||
$output->write(sprintf('Upgrading... from version <info>%s</info> to <info>%s</info>', $this->container['phraseanet.appbox']->get_version(), Version::getNumber()), true);
|
||||
|
||||
if (count(User_Adapter::get_wrong_email_users($this->container)) > 0) {
|
||||
return $output->writeln(sprintf('<error>You have to fix your database before upgrade with the system:mailCheck command </error>'));
|
||||
|
||||
Reference in New Issue
Block a user