Consider the connection option while aggregating the schemas

This commit is contained in:
Kévin Gomez 2013-11-03 22:20:01 +00:00
parent 7c7ac126e4
commit 41ebcdbaa7
2 changed files with 25 additions and 12 deletions

View file

@ -38,6 +38,12 @@ abstract class AbstractCommand extends ContainerAwareCommand
*/
protected $bundle = null;
/**
*
* @var InputInterface
*/
protected $input;
/**
* {@inheritdoc}
*/
@ -67,11 +73,11 @@ abstract class AbstractCommand extends ContainerAwareCommand
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupBuildTimeFiles();
$params = $this->getSubCommandArguments($input);
$command = $this->createSubCommandInstance();
$this->setupBuildTimeFiles();
return $this->runCommand($command, $params, $input, $output);
}
@ -82,13 +88,15 @@ abstract class AbstractCommand extends ContainerAwareCommand
{
parent::initialize($input, $output);
$this->input = $input;
$this->checkConfiguration();
if ($input->hasArgument('bundle') && '@' === substr($input->getArgument('bundle'), 0, 1)) {
if ($input->hasArgument('bundle') && !empty($input->getArgument('bundle'))) {
$this->bundle = $this
->getContainer()
->get('kernel')
->getBundle(substr($input->getArgument('bundle'), 1));
->getBundle($input->getArgument('bundle'));
}
}
@ -175,14 +183,17 @@ abstract class AbstractCommand extends ContainerAwareCommand
);
}
// @todo
//if ($this->input && $this->input->hasOption('connection') && $this->input->getOption('connection')
// && $database['name'] != $this->input->getOption('connection')) {
// //we skip this schema because the connection name doesn't match the input value
// unset($this->tempSchemas[$tempSchema]);
// $filesystem->remove($file);
// continue;
//}
if ($this->input->hasOption('connection')) {
$connections = $this->input->getOption('connection') ?: array($this->getContainer()->getParameter('propel.dbal.default_connection'));
if (!in_array($database['name'], $connections)) {
// we skip this schema because the connection name doesn't
// match the input values
unset($this->tempSchemas[$tempSchema]);
$filesystem->remove($file);
continue;
}
}
foreach ($database->table as $table) {
if (isset($table['package'])) {

View file

@ -11,6 +11,7 @@
namespace Propel\PropelBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
/**
@ -29,6 +30,7 @@ class ModelBuildCommand extends AbstractCommand
->setName('propel:model:build')
->setDescription('Build the model classes based on Propel XML schemas')
->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Connection to use. Example: default, bookstore')
->addArgument('bundle', InputArgument::OPTIONAL, 'The bundle to generate model classes from')
// @todo add the other arguments/options handled by the command
;