MigrationsGenerateDoctrineCommand.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Symfony\Framework\DoctrineBundle\Command;
  3. use Symfony\Components\Console\Input\InputInterface;
  4. use Symfony\Components\Console\Output\OutputInterface;
  5. use Symfony\Components\Console\Input\InputOption;
  6. use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand;
  7. /*
  8. * This file is part of the Symfony framework.
  9. *
  10. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  11. *
  12. * This source file is subject to the MIT license that is bundled
  13. * with this source code in the file LICENSE.
  14. */
  15. /**
  16. * Command for generating new blank migration classes
  17. *
  18. * @package Symfony
  19. * @subpackage Framework_DoctrineBundle
  20. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  21. * @author Jonathan H. Wage <jonwage@gmail.com>
  22. */
  23. class MigrationsGenerateDoctrineCommand extends GenerateCommand
  24. {
  25. protected function configure()
  26. {
  27. parent::configure();
  28. $this
  29. ->setName('doctrine:migrations:generate')
  30. ->addOption('bundle', null, InputOption::PARAMETER_REQUIRED, 'The bundle to load migrations configuration from.')
  31. ->addOption('em', null, InputOption::PARAMETER_OPTIONAL, 'The entity manager to use for this command.')
  32. ;
  33. }
  34. public function execute(InputInterface $input, OutputInterface $output)
  35. {
  36. DoctrineCommand::setApplicationEntityManager($this->application, $input->getOption('em'));
  37. $configuration = $this->_getMigrationConfiguration($input, $output);
  38. DoctrineCommand::configureMigrationsForBundle($this->application, $input->getOption('bundle'), $configuration);
  39. parent::execute($input, $output);
  40. }
  41. }