1 | <?php |
||
26 | abstract class AbstractCommand extends Command |
||
27 | { |
||
28 | /** |
||
29 | * The configuration property only contains the configuration injected by the setter. |
||
30 | * |
||
31 | * @var Configuration |
||
32 | */ |
||
33 | private $configuration; |
||
34 | |||
35 | /** |
||
36 | * The migrationConfiguration property contains the configuration |
||
37 | * created taking into account the command line options. |
||
38 | * |
||
39 | * @var Configuration |
||
40 | */ |
||
41 | private $migrationConfiguration; |
||
42 | |||
43 | /** |
||
44 | * @var OutputWriter |
||
45 | */ |
||
46 | private $outputWriter; |
||
47 | |||
48 | /** |
||
49 | * @var \Doctrine\DBAL\Connection |
||
50 | */ |
||
51 | private $connection; |
||
52 | |||
53 | 52 | protected function configure() |
|
54 | { |
||
55 | 52 | $this->addOption('configuration', null, InputOption::VALUE_OPTIONAL, 'The path to a migrations configuration file.'); |
|
56 | 52 | $this->addOption('db-configuration', null, InputOption::VALUE_OPTIONAL, 'The path to a database connection configuration file.'); |
|
57 | 52 | } |
|
58 | |||
59 | 11 | protected function outputHeader(Configuration $configuration, OutputInterface $output) |
|
60 | { |
||
61 | 11 | $name = $configuration->getName(); |
|
62 | 11 | $name = $name ? $name : 'Doctrine Database Migrations'; |
|
63 | 11 | $name = str_repeat(' ', 20) . $name . str_repeat(' ', 20); |
|
64 | 11 | $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>'); |
|
65 | 11 | $output->writeln('<question>' . $name . '</question>'); |
|
66 | 11 | $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>'); |
|
67 | 11 | $output->writeln(''); |
|
68 | 11 | } |
|
69 | |||
70 | 23 | public function setMigrationConfiguration(Configuration $config) |
|
74 | |||
75 | /** |
||
76 | * When any (config) command line option is passed to the migration the migrationConfiguration |
||
77 | * property is set with the new generated configuration. |
||
78 | * If no (config) option is passed the migrationConfiguration property is set to the value |
||
79 | * of the configuration one (if any). |
||
80 | * Else a new configuration is created and assigned to the migrationConfiguration property. |
||
81 | * |
||
82 | * @param InputInterface $input |
||
83 | * @param OutputInterface $output |
||
84 | * |
||
85 | * @return Configuration |
||
86 | */ |
||
87 | 36 | protected function getMigrationConfiguration(InputInterface $input, OutputInterface $output) |
|
101 | |||
102 | /** |
||
103 | * @param string $question |
||
104 | * @param InputInterface $input |
||
105 | * @param OutputInterface $output |
||
106 | * @return mixed |
||
107 | */ |
||
108 | 6 | protected function askConfirmation($question, InputInterface $input, OutputInterface $output) |
|
112 | |||
113 | /** |
||
114 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
115 | * |
||
116 | * @return \Doctrine\DBAL\Migrations\OutputWriter |
||
117 | */ |
||
118 | 35 | private function getOutputWriter(OutputInterface $output) |
|
128 | |||
129 | /** |
||
130 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
131 | * |
||
132 | * @return \Doctrine\DBAL\Connection |
||
133 | * @throws \Doctrine\DBAL\DBALException |
||
134 | */ |
||
135 | 35 | private function getConnection(InputInterface $input) |
|
157 | } |
||
158 |