redBean = $redBean; $this->database = $database; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setName('database:table:debug') ->setDescription($this->trans('commands.database.table.debug.description')) ->addOption( 'database', null, InputOption::VALUE_OPTIONAL, $this->trans('commands.database.table.debug.options.database'), 'default' ) ->addArgument( 'table', InputArgument::OPTIONAL, $this->trans('commands.database.table.debug.arguments.table'), null ) ->setHelp($this->trans('commands.database.table.debug.help')); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $database = $input->getOption('database'); $table = $input->getArgument('table'); $databaseConnection = $this->resolveConnection($io, $database); if ($table) { $this->redBean = $this->getRedBeanConnection($database); $tableInfo = $this->redBean->inspect($table); $tableHeader = [ $this->trans('commands.database.table.debug.messages.column'), $this->trans('commands.database.table.debug.messages.type') ]; $tableRows = []; foreach ($tableInfo as $column => $type) { $tableRows[] = [ 'column' => $column, 'type' => $type ]; } $io->table($tableHeader, $tableRows); return 0; } $schema = $this->database->schema(); $tables = $schema->findTables('%'); $io->comment( sprintf( $this->trans('commands.database.table.debug.messages.table-show'), $databaseConnection['database'] ) ); $io->table( [$this->trans('commands.database.table.debug.messages.table')], $tables ); return 0; } }