setName('plugin:list');
$this->setDescription('List installed plugins.');
$this->addOption('filter-plugin', null, InputOption::VALUE_OPTIONAL, 'If given, prints only plugins that contain this term.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$pluginManager = Manager::getInstance();
$plugins = $pluginManager->getInstalledPluginsName();
$pluginFilter = $input->getOption('filter-plugin');
if (!empty($pluginFilter)) {
$plugins = array_filter($plugins, function ($pluginName) use ($pluginFilter) {
return strpos($pluginName, $pluginFilter) !== false;
});
}
$plugins = array_map(function ($plugin) use ($pluginManager) {
return array(
'' . $plugin . '',
$pluginManager->isPluginBundledWithCore($plugin) ? 'Core' : 'Optional',
$pluginManager->isPluginActivated($plugin) ? 'Activated' : 'Not activated',
);
}, $plugins);
// Sort Core plugins first
usort($plugins, function ($a, $b) {
return strcmp($a[1], $b[1]);
});
$table = new Table($output);
$table
->setHeaders(array('Plugin', 'Core or optional?', 'Status'))
->setRows($plugins)
;
$table->render();
}
}