netz98 /
n98-magerun2
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace N98\Magento\Command\Database; |
||
| 4 | |||
| 5 | use Symfony\Component\Console\Input\InputInterface; |
||
| 6 | use Symfony\Component\Console\Input\InputOption; |
||
| 7 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 8 | |||
| 9 | class DropCommand extends AbstractDatabaseCommand |
||
| 10 | { |
||
| 11 | protected function configure() |
||
| 12 | { |
||
| 13 | $this |
||
| 14 | ->setName('db:drop') |
||
| 15 | ->addOption('tables', 't', InputOption::VALUE_NONE, 'Drop all tables instead of dropping the database') |
||
| 16 | ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force') |
||
| 17 | ->setDescription('Drop current database') |
||
| 18 | ; |
||
| 19 | |||
| 20 | $help = <<<HELP |
||
| 21 | The command prompts before dropping the database. If --force option is specified it |
||
| 22 | directly drops the database. |
||
| 23 | The configured user in app/etc/local.xml must have "DROP" privileges. |
||
| 24 | HELP; |
||
| 25 | $this->setHelp($help); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
| 30 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
| 31 | * @return int|void |
||
| 32 | */ |
||
| 33 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 34 | { |
||
| 35 | $this->detectDbSettings($output); |
||
| 36 | $dialog = $this->getHelperSet()->get('dialog'); |
||
| 37 | $dbHelper = $this->getHelper('database'); |
||
| 38 | |||
| 39 | if ($input->getOption('force')) { |
||
| 40 | $shouldDrop = true; |
||
| 41 | } else { |
||
| 42 | $shouldDrop = $dialog->askConfirmation($output, '<question>Really drop database ' . $this->dbSettings['dbname'] . ' ?</question> <comment>[n]</comment>: ', false); |
||
|
0 ignored issues
–
show
|
|||
| 43 | } |
||
| 44 | |||
| 45 | if ($shouldDrop) { |
||
| 46 | if ($input->getOption('tables')) { |
||
| 47 | $dbHelper->dropTables($output); |
||
| 48 | } else { |
||
| 49 | $dbHelper->dropDatabase($output); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.