Skip to content

Commit

Permalink
[console] Remove gabordemooij/redbean dependency. (#3799)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Feb 21, 2018
1 parent 08a0c78 commit 879e1b6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion config/services/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
24 changes: 8 additions & 16 deletions src/Command/Debug/DatabaseTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -82,30 +74,30 @@ 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'),
$database
)
);
}
$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'],
];
}

Expand Down

0 comments on commit 879e1b6

Please sign in to comment.