|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\MakerBundle\Maker; |
13 | 13 |
|
| 14 | +use Doctrine\Bundle\MigrationsBundle\Command\MigrationsDiffDoctrineCommand; |
14 | 15 | use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle; |
15 | 16 | use Symfony\Bundle\MakerBundle\ApplicationAwareMakerInterface; |
16 | 17 | use Symfony\Bundle\MakerBundle\Console\MigrationDiffFilteredOutput; |
@@ -56,25 +57,34 @@ public function configureCommand(Command $command, InputConfiguration $inputConf |
56 | 57 | { |
57 | 58 | $command |
58 | 59 | ->setDescription('Creates a new migration based on database changes') |
59 | | - ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection name') |
60 | | - ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager name') |
61 | | - ->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection name') |
62 | 60 | ->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeMigration.txt')) |
63 | 61 | ; |
| 62 | + |
| 63 | + if (class_exists(MigrationsDiffDoctrineCommand::class)) { |
| 64 | + // support for DoctrineMigrationsBundle 2.x |
| 65 | + $command |
| 66 | + ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection name') |
| 67 | + ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager name') |
| 68 | + ->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection name') |
| 69 | + ; |
| 70 | + } |
64 | 71 | } |
65 | 72 |
|
66 | 73 | public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) |
67 | 74 | { |
68 | 75 | $options = ['doctrine:migrations:diff']; |
69 | | - if (null !== $input->getOption('db')) { |
| 76 | + |
| 77 | + // DoctrineMigrationsBundle 2.x support |
| 78 | + if ($input->hasOption('db') && null !== $input->getOption('db')) { |
70 | 79 | $options[] = '--db='.$input->getOption('db'); |
71 | 80 | } |
72 | | - if (null !== $input->getOption('em')) { |
| 81 | + if ($input->hasOption('em') && null !== $input->getOption('em')) { |
73 | 82 | $options[] = '--em='.$input->getOption('em'); |
74 | 83 | } |
75 | | - if (null !== $input->getOption('shard')) { |
| 84 | + if ($input->hasOption('shard') && null !== $input->getOption('shard')) { |
76 | 85 | $options[] = '--shard='.$input->getOption('shard'); |
77 | 86 | } |
| 87 | + // end 2.x support |
78 | 88 |
|
79 | 89 | $generateMigrationCommand = $this->application->find('doctrine:migrations:diff'); |
80 | 90 |
|
|
0 commit comments