Elgg  Version master
UpgradeListCommand.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cli;
4 
6 
10 class UpgradeListCommand extends Command {
11 
15  protected function configure() {
16  $this->setName('upgrade:list')
17  ->setDescription(elgg_echo('cli:upgrade:list:description'));
18  }
19 
23  protected function command() {
24  $completed_upgrades = _elgg_services()->upgrades->getCompletedUpgrades();
25  if (!empty($completed_upgrades)) {
26  $table = new Table($this->output);
27 
28  $this->write(elgg_echo('cli:upgrade:list:completed'));
29 
30  foreach ($completed_upgrades as $upgrade) {
31  $table->addRow([
32  $upgrade->class,
33  $upgrade->getDisplayName(),
34  ]);
35  }
36 
37  $table->render();
38  }
39 
40  $pending_upgrades = _elgg_services()->upgrades->getPendingUpgrades();
41  if (!empty($pending_upgrades)) {
42  $table = new Table($this->output);
43 
44  $this->write(elgg_echo('cli:upgrade:list:pending'));
45 
46  foreach ($pending_upgrades as $upgrade) {
47  $table->addRow([
48  $upgrade->class,
49  $upgrade->getDisplayName(),
50  ]);
51  }
52 
53  $table->render();
54  }
55 
56  if (empty($completed_upgrades) && empty($pending_upgrades)) {
57  $this->write(elgg_echo('cli:upgrade:list:notfound'));
58  }
59 
60  return self::SUCCESS;
61  }
62 }
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(empty($guid)) $upgrade
Definition: upgrade.php:11
$table
Definition: user.php:37
write($messages, $level=LogLevel::INFO)
Write messages to output buffer.
Definition: BaseCommand.php:93
Abstract command with some utility methods.
Definition: Command.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346