5 * Contains \Drupal\Console\Command\Database\DropCommand.
8 namespace Drupal\Console\Command\Database;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Symfony\Component\Console\Command\Command;
14 use Drupal\Core\Database\Connection;
15 use Drupal\Console\Core\Command\Shared\CommandTrait;
16 use Drupal\Console\Command\Shared\ConnectTrait;
17 use Drupal\Console\Core\Style\DrupalStyle;
22 * @package Drupal\Console\Command\Database
24 class DropCommand extends Command
35 * DropCommand constructor.
37 * @param Connection $database
39 public function __construct(Connection $database)
41 $this->database = $database;
42 parent::__construct();
48 protected function configure()
51 ->setName('database:drop')
52 ->setDescription($this->trans('commands.database.drop.description'))
55 InputArgument::OPTIONAL,
56 $this->trans('commands.database.drop.arguments.database'),
59 ->setHelp($this->trans('commands.database.drop.help'));
65 protected function execute(InputInterface $input, OutputInterface $output)
67 $io = new DrupalStyle($input, $output);
68 $database = $input->getArgument('database');
69 $yes = $input->getOption('yes');
71 $databaseConnection = $this->resolveConnection($io, $database);
76 $this->trans('commands.database.drop.question.drop-tables'),
77 $databaseConnection['database']
86 $schema = $this->database->schema();
87 $tables = $schema->findTables('%');
90 foreach ($tables as $table) {
91 if ($schema->dropTable($table)) {
92 $tableRows['success'][] = [$table];
94 $tableRows['error'][] = [$table];
100 $this->trans('commands.database.drop.messages.table-drop'),
101 count($tableRows['success'])