Skip to content

Commit cb45af5

Browse files
committed
removing options that are gone in 3.x
1 parent 885f001 commit cb45af5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Maker/MakeMigration.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\MakerBundle\Maker;
1313

14+
use Doctrine\Bundle\MigrationsBundle\Command\MigrationsDiffDoctrineCommand;
1415
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
1516
use Symfony\Bundle\MakerBundle\ApplicationAwareMakerInterface;
1617
use Symfony\Bundle\MakerBundle\Console\MigrationDiffFilteredOutput;
@@ -56,25 +57,34 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
5657
{
5758
$command
5859
->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')
6260
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeMigration.txt'))
6361
;
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+
}
6471
}
6572

6673
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
6774
{
6875
$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')) {
7079
$options[] = '--db='.$input->getOption('db');
7180
}
72-
if (null !== $input->getOption('em')) {
81+
if ($input->hasOption('em') && null !== $input->getOption('em')) {
7382
$options[] = '--em='.$input->getOption('em');
7483
}
75-
if (null !== $input->getOption('shard')) {
84+
if ($input->hasOption('shard') && null !== $input->getOption('shard')) {
7685
$options[] = '--shard='.$input->getOption('shard');
7786
}
87+
// end 2.x support
7888

7989
$generateMigrationCommand = $this->application->find('doctrine:migrations:diff');
8090

0 commit comments

Comments
 (0)