flarum info: Extract extension table to function

This commit is contained in:
Franz Liedke 2018-09-04 00:35:38 +02:00
parent 092e5b9d23
commit eb228dd7b9
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4

View File

@ -64,35 +64,7 @@ class InfoCommand extends AbstractCommand
$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());
@ -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('<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.
*