Skip to content

Commit

Permalink
flarum info: Extract extension table to function
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Sep 3, 2018
1 parent 092e5b9 commit eb228dd
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions src/Foundation/Console/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,7 @@ protected function fire()
$phpExtensions = implode(', ', get_loaded_extensions());
$this->output->writeln("<info>Loaded extensions:</info> $phpExtensions");

$table = new Table($this->output);
$table->setHeaders([
[
'Flarum Extensions'
],
[
'ID',
'Version',
'Commit'
]
])->setStyle(
(new TableStyle())
->setCellHeaderFormat('<info>%s</info>')
);

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('<info>Base URL:</info> '.$this->config['url']);
$this->output->writeln('<info>Installation path:</info> '.getcwd());
Expand All @@ -105,6 +77,27 @@ protected function fire()
}
}

private function getExtensionTable()
{
$table = (new Table($this->output))
->setHeaders([
['Flarum Extensions'],
['ID', 'Version', 'Commit']
])->setStyle(
(new TableStyle)->setCellHeaderFormat('<info>%s</info>')
);

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.
*
Expand Down

0 comments on commit eb228dd

Please sign in to comment.