5 * Contains \Drupal\Console\Command\Database\TableDebugCommand.
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\Input\InputOption;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Symfony\Component\Console\Command\Command;
16 use Drupal\Core\Database\Connection;
17 use Drupal\Console\Core\Command\Shared\CommandTrait;
18 use Drupal\Console\Core\Style\DrupalStyle;
19 use Drupal\Console\Command\Shared\ConnectTrait;
22 * Class TableDebugCommand
24 * @package Drupal\Console\Command\Database
26 class TableDebugCommand extends Command
42 * TableDebugCommand constructor.
45 * @param Connection $database
47 public function __construct(
51 $this->redBean = $redBean;
52 $this->database = $database;
53 parent::__construct();
59 protected function configure()
62 ->setName('database:table:debug')
63 ->setDescription($this->trans('commands.database.table.debug.description'))
67 InputOption::VALUE_OPTIONAL,
68 $this->trans('commands.database.table.debug.options.database'),
73 InputArgument::OPTIONAL,
74 $this->trans('commands.database.table.debug.arguments.table'),
77 ->setHelp($this->trans('commands.database.table.debug.help'));
83 protected function execute(InputInterface $input, OutputInterface $output)
85 $io = new DrupalStyle($input, $output);
86 $database = $input->getOption('database');
87 $table = $input->getArgument('table');
89 $databaseConnection = $this->resolveConnection($io, $database);
92 $this->redBean = $this->getRedBeanConnection($database);
93 $tableInfo = $this->redBean->inspect($table);
96 $this->trans('commands.database.table.debug.messages.column'),
97 $this->trans('commands.database.table.debug.messages.type')
100 foreach ($tableInfo as $column => $type) {
107 $io->table($tableHeader, $tableRows);
112 $schema = $this->database->schema();
113 $tables = $schema->findTables('%');
117 $this->trans('commands.database.table.debug.messages.table-show'),
118 $databaseConnection['database']
123 [$this->trans('commands.database.table.debug.messages.table')],