Elgg  Version 3.0
PluginsListCommand.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cli;
4 
7 
11 class PluginsListCommand extends Command {
12 
16  protected function configure() {
17  $this->setName('plugins:list')
18  ->setDescription('List all plugins installed on the site')
19  ->addOption('status', 's', InputOption::VALUE_OPTIONAL,
20  'Plugin status ( all | active | inactive )'
21  );
22  }
23 
27  protected function command() {
28 
29  $status = $this->option('status') ? : 'all';
30  if (!in_array($status, ['all', 'active', 'inactive'])) {
31  $this->error("$status is not a valid status. Use 'all', 'active' or 'inactive'");
32  return 1;
33  }
34 
35  $table = new Table($this->output);
36  $table->setHeaders(['GUID', 'ID', 'Version', 'Status', 'Priority']);
37 
38  try {
39  $plugins = elgg_get_plugins($status);
40 
41  foreach ($plugins as $plugin) {
42  $manifest = $plugin->getManifest();
43 
44  $table->addRow([
45  $plugin->guid,
46  $plugin->getID(),
47  $manifest ? $manifest->getVersion() : 'INVALID PACKAGE',
48  $plugin->isActive() ? 'active' : 'inactive',
49  $plugin->getPriority(),
50  ]);
51  }
52 
53  $table->render();
54  } catch (\PluginException $ex) {
55  return 2;
56  }
57 
58  return 0;
59  }
60 }
$plugin
elgg-cli plugins:list [–status]
error($message)
Print an error.
$plugins
Definition: categories.php:3
PluginException.
Abstract command with some utility methods.
Definition: Command.php:12
elgg_get_plugins($status= 'active')
Returns an ordered list of plugins.
Definition: plugins.php:76
$table
Definition: cron.php:57
option($name)
Returns option value.