Skip to content

Commit

Permalink
Merge fa25936 into f6f7643
Browse files Browse the repository at this point in the history
  • Loading branch information
pscheit committed Nov 13, 2013
2 parents f6f7643 + fa25936 commit 05ffac8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
8 changes: 4 additions & 4 deletions lib/Webforge/Doctrine/Console/AbstractDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
namespace Webforge\Doctrine\Console;

use Webforge\Doctrine\Container as DoctrineContainer;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputOption;
use Webforge\Common\System\System;

abstract class AbstractDoctrineCommand extends SymfonyCommand {
abstract class AbstractDoctrineCommand extends \Webforge\Console\Command\CommandAdapter {

/**
* Webforge\Doctrine\Container
*/
protected $dcc;

public function __construct(DoctrineContainer $dcc) {
public function __construct(DoctrineContainer $dcc, System $system) {
$this->dcc = $dcc;
parent::__construct();
parent::__construct($this->name, $system);
}

protected function configure() {
Expand Down
8 changes: 6 additions & 2 deletions lib/Webforge/Doctrine/Console/ConsoleBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand;
use Webforge\Doctrine\Container as DoctrineContainer;
use Webforge\Common\System\System;

class ConsoleBridge {

Expand All @@ -14,8 +15,11 @@ class ConsoleBridge {
*/
protected $dcc;

public function __construct(DoctrineContainer $dcc) {
protected $system;

public function __construct(DoctrineContainer $dcc, System $system) {
$this->dcc = $dcc;
$this->system = $system;
}

public function augment($application) {
Expand All @@ -26,7 +30,7 @@ public function augment($application) {

$application->addCommands(array(
new ValidateSchemaCommand(),
new ORMUpdateSchemaCommand($this->dcc)
new ORMUpdateSchemaCommand($this->dcc, $this->system)
));
}
}
22 changes: 13 additions & 9 deletions lib/Webforge/Doctrine/Console/ORMUpdateSchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
namespace Webforge\Doctrine\Console;

use Webforge\Doctrine\Util;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Webforge\Console\CommandInput;
use Webforge\Console\CommandOutput;
use Webforge\Console\CommandInteraction;
use Webforge\Common\System\System;

class ORMUpdateSchemaCommand extends AbstractDoctrineCommand {

protected $name = 'orm:update-schema';

protected function configure() {
$this
->setName('orm:update-schema')
Expand All @@ -25,22 +29,22 @@ protected function configure() {
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output) {
$force = ($input->getOption('dry-run') !== TRUE) ? Util::FORCE : NULL;
$con = $input->getOption('con');
public function doExecute(CommandInput $input, CommandOutput $output, CommandInteraction $interact, System $system) {
$force = !$input->getFlag('dry-run') ? Util::FORCE : NULL;
$con = $input->getValue('con');

$util = $this->dcc->getUtil();

if ($force == Util::FORCE) {
$output->writeln('Updating schema (forced) for connection: '.$con);
$output->warn('Updating schema (forced) for connection: '.$con);
} else {
$output->writeln('Printing update schema SQL for Connection: '.$con);
$output->msg('Printing update schema SQL for Connection: '.$con);
}

$output->writeln($log = $util->updateSchema($con, $force, "\n"));
$output->msg($log = $util->updateSchema($con, $force, "\n"));

if ($force !== Util::FORCE && empty($log)) {
$output->writeln('nothing to do');
$output->msg('nothing to do');
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/Webforge/Doctrine/Console/ConsoleBridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function setUp() {
parent::setUp();

$this->dcc->injectEntityManager($this->mocker->createEntityManager());
$this->consoleBridge = new ConsoleBridge($this->dcc);
$this->consoleBridge = new ConsoleBridge($this->dcc, $this->frameworkHelper->getSystem());

$this->application = new \Symfony\Component\Console\Application();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function setUp() {

$this->application = new Application();
$this->application->addCommands(array(
new ORMUpdateSchemaCommand($this->dcc)
new ORMUpdateSchemaCommand($this->dcc, $this->frameworkHelper->getSystem())
));
}

Expand Down

0 comments on commit 05ffac8

Please sign in to comment.