From eb228dd7b93a88d75e2003caf6140ee0b5661da6 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 4 Sep 2018 00:35:38 +0200 Subject: [PATCH] flarum info: Extract extension table to function --- src/Foundation/Console/InfoCommand.php | 51 +++++++++++--------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/src/Foundation/Console/InfoCommand.php b/src/Foundation/Console/InfoCommand.php index 520cbc1d0..f694a31eb 100644 --- a/src/Foundation/Console/InfoCommand.php +++ b/src/Foundation/Console/InfoCommand.php @@ -64,35 +64,7 @@ class InfoCommand extends AbstractCommand $phpExtensions = implode(', ', get_loaded_extensions()); $this->output->writeln("Loaded extensions: $phpExtensions"); - $table = new Table($this->output); - $table->setHeaders([ - [ - 'Flarum Extensions' - ], - [ - 'ID', - 'Version', - 'Commit' - ] - ])->setStyle( - (new TableStyle()) - ->setCellHeaderFormat('%s') - ); - - foreach ($this->extensions->getEnabledExtensions() as $extension) { - /* @var \Flarum\Extension\Extension $extension */ - $name = $extension->getId(); - $fallback = $extension->getVersion(); - $version = $this->findPackageVersion($extension->getPath()); - - $table->addRow([ - $name, - $fallback, - $version - ]); - } - - $table->render(); + $this->getExtensionTable()->render(); $this->output->writeln('Base URL: '.$this->config['url']); $this->output->writeln('Installation path: '.getcwd()); @@ -105,6 +77,27 @@ class InfoCommand extends AbstractCommand } } + private function getExtensionTable() + { + $table = (new Table($this->output)) + ->setHeaders([ + ['Flarum Extensions'], + ['ID', 'Version', 'Commit'] + ])->setStyle( + (new TableStyle)->setCellHeaderFormat('%s') + ); + + foreach ($this->extensions->getEnabledExtensions() as $extension) { + $table->addRow([ + $extension->getId(), + $extension->getVersion(), + $this->findPackageVersion($extension->getPath()) + ]); + } + + return $table; + } + /** * Try to detect a package's exact version. *