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