doctrine /
DoctrineMigrationsBundle
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Doctrine\Bundle\MigrationsBundle\Command; |
||
| 6 | |||
| 7 | use Doctrine\Migrations\Tools\Console\Command\DiffCommand; |
||
| 8 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
||
| 9 | use Symfony\Component\Console\Input\InputInterface; |
||
| 10 | use Symfony\Component\Console\Input\InputOption; |
||
| 11 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Command for generate migration classes by comparing your current database schema |
||
| 15 | * to your mapping information. |
||
| 16 | */ |
||
| 17 | class MigrationsDiffDoctrineCommand extends DiffCommand |
||
| 18 | { |
||
| 19 | protected function configure() : void |
||
| 20 | { |
||
| 21 | parent::configure(); |
||
| 22 | |||
| 23 | $this |
||
| 24 | ->setName('doctrine:migrations:diff') |
||
| 25 | ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') |
||
| 26 | ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command.') |
||
| 27 | ->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection to use for this command.') |
||
| 28 | ; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function initialize(InputInterface $input, OutputInterface $output) : void |
||
| 32 | { |
||
| 33 | /** @var Application $application */ |
||
| 34 | $application = $this->getApplication(); |
||
| 35 | |||
| 36 | Helper\DoctrineCommandHelper::setApplicationHelper($application, $input); |
||
| 37 | |||
| 38 | $configuration = $this->getMigrationConfiguration($input, $output); |
||
| 39 | DoctrineCommand::configureMigrations($application->getKernel()->getContainer(), $configuration); |
||
| 40 | |||
| 41 | parent::initialize($input, $output); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function execute(InputInterface $input, OutputInterface $output) : ?int |
||
| 45 | { |
||
| 46 | // EM and DB options cannot be set at same time |
||
| 47 | if ($input->getOption('em') !== null && $input->getOption('db') !== null) { |
||
| 48 | throw new InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 49 | } |
||
| 50 | |||
| 51 | return parent::execute($input, $output); |
||
| 52 | } |
||
| 53 | } |
||
| 54 |