Changed getConnection return to get the name of the connection
This commit is contained in:
parent
5576005b6d
commit
7fbd755f05
|
@ -28,7 +28,7 @@ class DataDumpCommand extends PhingCommand
|
|||
->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use')
|
||||
->setHelp(<<<EOT
|
||||
The <info>propel:data-dump</info> dumps data from database into xml file.
|
||||
|
||||
|
||||
<info>php app/console propel:data-dump</info>
|
||||
|
||||
The <info>--connection</info> parameter allows you to change the connection to use.
|
||||
|
@ -46,7 +46,7 @@ EOT
|
|||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$defaultConfig = $this->getConnection($input, $output);
|
||||
list($name, $defaultConfig) = $this->getConnection($input, $output);
|
||||
|
||||
$this->callPhing('datadump', array(
|
||||
'propel.database.url' => $defaultConfig['connection']['dsn'],
|
||||
|
|
|
@ -45,7 +45,7 @@ EOT
|
|||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if ($input->getOption('force')) {
|
||||
$defaultConfig = $this->getConnection($input, $output);
|
||||
list($name, $defaultConfig) = $this->getConnection($input, $output);
|
||||
|
||||
$this->callPhing('insert-sql', array(
|
||||
'propel.database.url' => $defaultConfig['connection']['dsn'],
|
||||
|
|
|
@ -60,8 +60,6 @@ EOT
|
|||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$defaultConfig = $this->getConnection($input, $output);
|
||||
|
||||
$finder = new Finder();
|
||||
$filesystem = new Filesystem();
|
||||
$dir = $input->getOption('dir') ?: $this->defaultFixturesDir;
|
||||
|
|
|
@ -255,13 +255,13 @@ EOT;
|
|||
|
||||
/**
|
||||
* Get connection by checking the input option named 'connection'.
|
||||
* Returns the default connection if no option specified or an exception
|
||||
* Returns the default connection if no option specified or an exception
|
||||
* if the specified connection doesn't exist.
|
||||
*
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @throw \InvalidArgumentException If the connection does not exist.
|
||||
* @return array A Propel Configuration as an array.
|
||||
* @return array
|
||||
*/
|
||||
protected function getConnection(InputInterface $input, OutputInterface $output) {
|
||||
$container = $this->getApplication()->getKernel()->getContainer();
|
||||
|
@ -277,7 +277,7 @@ EOT;
|
|||
|
||||
$output->writeln(sprintf('<info>Use connection named <comment>%s</comment></info>', $name));
|
||||
|
||||
return $defaultConfig;
|
||||
return array($name, $defaultConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,19 +9,10 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\Util\Filesystem;
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ReverseCommand.
|
||||
*
|
||||
* @author William DURAND <william.durand1@gmail.com>
|
||||
* @author William DURAND <william.durand1@gmail.com>
|
||||
*/
|
||||
class ReverseCommand extends PhingCommand
|
||||
{
|
||||
|
@ -35,7 +26,6 @@ class ReverseCommand extends PhingCommand
|
|||
->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use')
|
||||
->setHelp(<<<EOT
|
||||
The <info>propel:reverse</info> command generates an XML schema from reverse-engineered database.
|
||||
|
||||
<info>php app/console propel:reverse</info>
|
||||
|
||||
The <info>--connection</info> parameter allows you to change the connection to use.
|
||||
|
@ -44,6 +34,7 @@ EOT
|
|||
)
|
||||
->setName('propel:reverse')
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,18 +43,8 @@ EOT
|
|||
* @throws \InvalidArgumentException When the target directory does not exist
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$container = $this->getApplication()->getKernel()->getContainer();
|
||||
$propelConfiguration = $container->get('propel.configuration');
|
||||
$name = $input->getOption('connection') ? $input->getOption('connection') : $container->getParameter('propel.dbal.default_connection');
|
||||
|
||||
if (isset($propelConfiguration['datasources'][$name])) {
|
||||
$defaultConfig = $propelConfiguration['datasources'][$name];
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('Connection named %s doesn\'t exist', $name));
|
||||
}
|
||||
|
||||
$output->writeln(sprintf('<info>Generate XML schema from connection named <comment>%s</comment></info>', $name));
|
||||
{
|
||||
list($name, $defaultConfig) = $this->getConnection($input, $output);
|
||||
|
||||
$this->callPhing('reverse', array(
|
||||
'propel.project' => $name,
|
||||
|
@ -77,6 +58,6 @@ EOT
|
|||
$dest = $this->getApplication()->getKernel()->getRootDir() . '/propel/' . $name . '_reversed_schema.xml';
|
||||
$filesystem->copy($this->getTmpDir().'/schema.xml', $dest);
|
||||
|
||||
$output->writeln(sprintf('New generated schema is "<info>%s</info>".', $dest));
|
||||
$output->writeln(sprintf('New generated schema is <comment>%s</comment>.', $dest));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue