Files
core/src/Command/ExtensionsListCommand.php
Bob den Otter 38b2b51e3a Worky, worky
2019-08-02 17:18:07 +02:00

54 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Bolt\Command;
use Bolt\Extension\ExtensionRegistry;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class ExtensionsListCommand extends Command
{
protected static $defaultName = 'extensions:list';
/** @var ExtensionRegistry */
private $extensionRegistry;
public function __construct(ExtensionRegistry $extensionRegistry)
{
$this->extensionRegistry = $extensionRegistry;
parent::__construct();
}
protected function configure(): void
{
$this
->setDescription('List extensions');
}
protected function execute(InputInterface $input, OutputInterface $output): ?int
{
$extensions = $this->extensionRegistry->getExtensions();
$rows = [];
foreach ($extensions as $extension) {
$rows[] = [$extension->getClass(), $extension->getName()];
}
$io = new SymfonyStyle($input, $output);
if (! empty($rows)) {
$io->table(['Class', 'Extension name'], $rows);
} else {
$io->caution('No installed extensions could be found');
}
return 0;
}
}