Skip to content

Commit

Permalink
MigrationsExtension: simplify configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Aug 14, 2016
1 parent 3dd7e26 commit a6a4796
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/Bridges/NetteDI/MigrationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ class MigrationsExtension extends Nette\DI\CompilerExtension
'dbal' => NULL,
'diffGenerator' => TRUE, // false|doctrine
'handlers' => [],
'configuration' => 'Nextras\Migrations\Configurations\DefaultConfiguration',
'withDummyData' => FALSE,
'commands' => [
'continue' => 'Nextras\Migrations\Bridges\SymfonyConsole\ContinueCommand',
'create' => 'Nextras\Migrations\Bridges\SymfonyConsole\CreateCommand',
'reset' => 'Nextras\Migrations\Bridges\SymfonyConsole\ResetCommand',
],
'contentSource' => NULL, // CreateCommand::CONTENT_SOURCE_*
'ignoredQueriesFile' => NULL,
];
Expand Down Expand Up @@ -82,18 +76,23 @@ public function loadConfiguration()
}

$configuration = $builder->addDefinition($this->prefix('configuration'))
->setClass($config['configuration'])
->setClass('Nextras\Migrations\Configurations\DefaultConfiguration')
->setArguments([$config['dir'], $handlers, $config['withDummyData']]);


$builder->addExcludedClasses(['Nextras\Migrations\Bridges\SymfonyConsole\BaseCommand']);
foreach (array_filter($config['commands']) as $name => $commandClass) {
// filter NULLed command classes to enable disabling default command completely
$builder->addDefinition($this->prefix("{$name}Command"))
->setClass($commandClass)
->setArguments([$driver, $configuration])
->addTag('kdyby.console.command');
}
$builder->addDefinition($this->prefix("continueCommand"))
->setClass('Nextras\Migrations\Bridges\SymfonyConsole\ContinueCommand')
->setArguments([$driver, $configuration])
->addTag('kdyby.console.command');
$builder->addDefinition($this->prefix("createCommand"))
->setClass('Nextras\Migrations\Bridges\SymfonyConsole\CreateCommand')
->setArguments([$driver, $configuration])
->addTag('kdyby.console.command');
$builder->addDefinition($this->prefix("resetCommand"))
->setClass('Nextras\Migrations\Bridges\SymfonyConsole\ResetCommand')
->setArguments([$driver, $configuration])
->addTag('kdyby.console.command');

if ($config['diffGenerator'] !== FALSE) {
$builder->addDefinition($this->prefix('structureDiffGenerator'))
Expand Down

0 comments on commit a6a4796

Please sign in to comment.