Skip to content

Commit

Permalink
fixed relaying tasks that don't recognize about "application" and "en…
Browse files Browse the repository at this point in the history
…v" option (refs openpne#347)
  • Loading branch information
Kousuke Ebihara committed Jan 6, 2010
1 parent d4a1d57 commit ec219c0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
28 changes: 17 additions & 11 deletions lib/task/openpneInstallTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function execute($arguments = array(), $options = array())
return 1;
}

$this->doInstall($dbms, $username, $password, $hostname, $port, $dbname, $sock);
$this->doInstall($dbms, $username, $password, $hostname, $port, $dbname, $sock, $options);

if ($dbms === 'sqlite')
{
Expand All @@ -103,13 +103,13 @@ protected function execute($arguments = array(), $options = array())
$this->logSection('installer', 'installation is completed!');
}

protected function doInstall($dbms, $username, $password, $hostname, $port, $dbname, $sock)
protected function doInstall($dbms, $username, $password, $hostname, $port, $dbname, $sock, $options)
{
$this->installPlugins();
@$this->fixPerms();
@$this->clearCache();
$this->configureDatabase($dbms, $username, $password, $hostname, $port, $dbname, $sock);
$this->buildDb();
$this->configureDatabase($dbms, $username, $password, $hostname, $port, $dbname, $sock, $options);
$this->buildDb($options);
}

protected function createDSN($dbms, $hostname, $port, $dbname, $sock)
Expand Down Expand Up @@ -149,21 +149,25 @@ protected function createDSN($dbms, $hostname, $port, $dbname, $sock)
return $result;
}

protected function configureDatabase($dbms, $username, $password, $hostname, $port, $dbname, $sock)
protected function configureDatabase($dbms, $username, $password, $hostname, $port, $dbname, $sock, $options)
{
$dsn = $this->createDSN($dbms, $hostname, $port, $dbname, $sock);

$file = sfConfig::get('sf_config_dir').'/databases.yml';
$config = array('dev' => array('doctrine' => array('param' => array(
'classname' => 'DebugPDO',
))));
$config = array();

if (file_exists($file))
{
$config = sfYaml::load($file);
}

$config['all']['doctrine'] = array(
$env = 'all';
if ('prod' !== $options['env'])
{
$env = $options['env'];
}

$config[$env]['doctrine'] = array(
'class' => 'sfDoctrineDatabase',
'param' => array(
'dsn' => $dsn,
Expand All @@ -177,7 +181,7 @@ protected function configureDatabase($dbms, $username, $password, $hostname, $po

if ($password)
{
$config['all']['doctrine']['param']['password'] = $password;
$config[$env]['doctrine']['param']['password'] = $password;
}

file_put_contents($file, sfYaml::dump($config, 4));
Expand All @@ -195,7 +199,7 @@ protected function publishAssets()
$publishAssets->run();
}

protected function buildDb()
protected function buildDb($options)
{
$tmpdir = sfConfig::get('sf_data_dir').'/fixtures_tmp';
$this->getFilesystem()->mkdirs($tmpdir);
Expand Down Expand Up @@ -228,6 +232,8 @@ protected function buildDb()
'filters' => true,
'sql' => true,
'and-load' => $tmpdir,
'application' => $options['application'],
'env' => $options['env'],
));

$this->getFilesystem()->remove(sfFinder::type('file')->in(array($tmpdir)));
Expand Down
6 changes: 4 additions & 2 deletions lib/task/openpneMigrateTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function execute($arguments = array(), $options = array())

if (!$options['no-build-model'])
{
$this->buildModel();
$this->buildModel($options);
}

foreach ($installedPlugins as $v)
Expand Down Expand Up @@ -192,7 +192,7 @@ protected function throwSpecifiedException(Exception $e)
}
}

protected function buildModel()
protected function buildModel($options)
{
$task = new sfDoctrineBuildTask($this->dispatcher, $this->formatter);
$task->setCommandApplication($this->commandApplication);
Expand All @@ -202,6 +202,8 @@ protected function buildModel()
'model' => true,
'forms' => true,
'filters' => true,
'application' => $options['application'],
'env' => $options['env'],
));

$task = new sfCacheClearTask($this->dispatcher, $this->formatter);
Expand Down
2 changes: 2 additions & 0 deletions test/bootstrap/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
'no-confirmation' => true,
'db' => true,
'and-load' => dirname(__FILE__).'/../fixtures',
'application' => $_app,
'env' => $_env,
));

0 comments on commit ec219c0

Please sign in to comment.