From 879e1b6db0ee221802095280f029e6988c999569 Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Tue, 20 Feb 2018 21:24:37 -0800 Subject: [PATCH] [console] Remove gabordemooij/redbean dependency. (#3799) --- composer.json | 1 - config/services/debug.yml | 2 +- services.yml | 2 -- src/Command/Debug/DatabaseTableCommand.php | 24 ++++++++-------------- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index bf1a3f1a8..003d13cc3 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,6 @@ "drupal/console-core": "dev-master", "drupal/console-dotenv": "~0", "drupal/console-extend-plugin": "~0", - "gabordemooij/redbean": "~4.3", "guzzlehttp/guzzle": "~6.1", "psy/psysh": "0.6.* || ~0.8", "symfony/css-selector": "~2.8|~3.0", diff --git a/config/services/debug.yml b/config/services/debug.yml index e1407602e..7d04fefff 100644 --- a/config/services/debug.yml +++ b/config/services/debug.yml @@ -87,7 +87,7 @@ services: - { name: drupal.command } console.database_table_debug: class: Drupal\Console\Command\Debug\DatabaseTableCommand - arguments: ['@console.redbean', '@database'] + arguments: ['@database'] tags: - { name: drupal.command } console.cron_debug: diff --git a/services.yml b/services.yml index a7c3ab81e..b0d4597c6 100644 --- a/services.yml +++ b/services.yml @@ -3,8 +3,6 @@ services: class: SplString console.cache_key: class: SplString - console.redbean: - class: RedBeanPHP\R console.validator: class: Drupal\Console\Utils\Validator arguments: ['@console.extension_manager', '@console.translator_manager'] diff --git a/src/Command/Debug/DatabaseTableCommand.php b/src/Command/Debug/DatabaseTableCommand.php index f6f0f2225..5f0768e1b 100644 --- a/src/Command/Debug/DatabaseTableCommand.php +++ b/src/Command/Debug/DatabaseTableCommand.php @@ -30,22 +30,14 @@ class DatabaseTableCommand extends Command */ protected $database; - /** - * @var R - */ - protected $redBean; - /** * DatabaseTableCommand constructor. * - * @param R $redBean * @param Connection $database */ public function __construct( - R $redBean, Connection $database ) { - $this->redBean = $redBean; $this->database = $database; parent::__construct(); } @@ -82,12 +74,12 @@ protected function execute(InputInterface $input, OutputInterface $output) { $database = $input->getOption('database'); $table = $input->getArgument('table'); - $databaseConnection = $this->resolveConnection($database); - if ($table) { - $this->redBean = $this->getRedBeanConnection($database); - if (empty($this->redBean)) { + $result = $this->database + ->query('DESCRIBE '. $table .';') + ->fetchAll(); + if (!$result) { throw new \Exception( sprintf( $this->trans('commands.debug.database.table.messages.no-connection'), @@ -95,17 +87,17 @@ protected function execute(InputInterface $input, OutputInterface $output) ) ); } - $tableInfo = $this->redBean->inspect($table); $tableHeader = [ $this->trans('commands.debug.database.table.messages.column'), $this->trans('commands.debug.database.table.messages.type') ]; $tableRows = []; - foreach ($tableInfo as $column => $type) { + foreach ($result as $record) { + $column = json_decode(json_encode($record), true); $tableRows[] = [ - 'column' => $column, - 'type' => $type + 'column' => $column['Field'], + 'type' => $column['Type'], ]; }