mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 12:43:52 +08:00
flarum info: Extract extension table to function
This commit is contained in:
parent
092e5b9d23
commit
eb228dd7b9
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user