diff --git a/src/Command/State/DebugCommand.php b/src/Command/State/DebugCommand.php index 3622c5469..5bc4b219e 100644 --- a/src/Command/State/DebugCommand.php +++ b/src/Command/State/DebugCommand.php @@ -7,7 +7,6 @@ namespace Drupal\Console\Command\State; -use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -47,31 +46,17 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($key) { $state = $this->getState(); - $io->writeln( - sprintf( - '%s:', - $key - ) - ); + $io->info($key); $io->writeln(Yaml::encode($state->get($key))); + return; } - $this->showAllStateKeys($io); - } - /** - * @param \Drupal\Console\Style\DrupalStyle $io - */ - private function showAllStateKeys(DrupalStyle $io) - { - $table = new Table($io); - $table->setStyle('compact'); - $table->setHeaders([$this->trans('commands.state.debug.messages.key')]); - $keyValue = $this->getContainer()->get('keyvalue'); + $tableHeader = [$this->trans('commands.state.debug.messages.key')]; + + $keyValue = $this->hasGetService('keyvalue'); $keyStoreStates = array_keys($keyValue->get('state')->getAll()); - foreach ($keyStoreStates as $key => $keyStoreState) { - $table->addRow([$keyStoreState]); - } - $table->render(); + + $io->table($tableHeader, $keyStoreStates); } } diff --git a/src/Command/State/OverrideCommand.php b/src/Command/State/OverrideCommand.php index 4e65658db..d2d15635a 100644 --- a/src/Command/State/OverrideCommand.php +++ b/src/Command/State/OverrideCommand.php @@ -7,7 +7,6 @@ namespace Drupal\Console\Command\State; -use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -59,20 +58,22 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($key && $value) { - $table = new Table($io); $state = $this->getState(); $originalValue = Yaml::encode($state->get($key)); $overrideValue = is_array($value)?Yaml::encode($value):$value; $state->set($key, $overrideValue); - $table->setHeaders( - [ - $this->trans('commands.state.override.messages.key'), - $this->trans('commands.state.override.messages.original'), - $this->trans('commands.state.override.messages.override') - ] + $tableHeaders = [ + $this->trans('commands.state.override.messages.key'), + $this->trans('commands.state.override.messages.original'), + $this->trans('commands.state.override.messages.override') + ]; + + $tableRows[] = [$key, $originalValue, $overrideValue]; + + $io->table( + $tableHeaders, + $tableRows ); - $table->addRow([$key, $originalValue, $overrideValue]); - $table->render(); } } }