1 | <?php |
||
37 | class GenerateCommand extends AbstractCommand |
||
38 | { |
||
39 | |||
40 | private static $_template = |
||
41 | '<?php |
||
42 | |||
43 | namespace <namespace>; |
||
44 | |||
45 | use Doctrine\DBAL\Migrations\AbstractMigration; |
||
46 | use Doctrine\DBAL\Schema\Schema; |
||
47 | |||
48 | /** |
||
49 | * Auto-generated Migration: Please modify to your needs! |
||
50 | */ |
||
51 | class Version<version> extends AbstractMigration |
||
52 | { |
||
53 | /** |
||
54 | * @param Schema $schema |
||
55 | */ |
||
56 | public function up(Schema $schema) |
||
57 | { |
||
58 | // this up() migration is auto-generated, please modify it to your needs |
||
59 | <up> |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param Schema $schema |
||
64 | */ |
||
65 | public function down(Schema $schema) |
||
66 | { |
||
67 | // this down() migration is auto-generated, please modify it to your needs |
||
68 | <down> |
||
69 | } |
||
70 | } |
||
71 | '; |
||
72 | |||
73 | 10 | protected function configure() |
|
74 | { |
||
75 | $this |
||
76 | 10 | ->setName('migrations:generate') |
|
77 | 10 | ->setDescription('Generate a blank migration class.') |
|
78 | 10 | ->addOption('editor-cmd', null, InputOption::VALUE_OPTIONAL, 'Open file with this command upon creation.') |
|
79 | 10 | ->setHelp(<<<EOT |
|
80 | The <info>%command.name%</info> command generates a blank migration class: |
||
81 | |||
82 | <info>%command.full_name%</info> |
||
83 | |||
84 | You can optionally specify a <comment>--editor-cmd</comment> option to open the generated file in your favorite editor: |
||
85 | |||
86 | 10 | <info>%command.full_name% --editor-cmd=mate</info> |
|
87 | EOT |
||
88 | ); |
||
89 | |||
90 | 10 | parent::configure(); |
|
91 | 10 | } |
|
92 | |||
93 | 3 | public function execute(InputInterface $input, OutputInterface $output) |
|
94 | { |
||
95 | 3 | $configuration = $this->getMigrationConfiguration($input, $output); |
|
96 | |||
97 | 3 | $version = $configuration->generateVersionNumber(); |
|
98 | 3 | $path = $this->generateMigration($configuration, $input, $version); |
|
99 | |||
100 | 3 | $output->writeln(sprintf('Generated new migration class to "<info>%s</info>"', $path)); |
|
101 | 3 | } |
|
102 | |||
103 | 9 | protected function getTemplate() |
|
107 | |||
108 | 9 | protected function generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null) |
|
109 | { |
||
136 | } |
||
137 |