Elgg  Version master
DeleteDiagnosticsPlugin.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrades;
4 
7 
12 
16  public function getVersion(): int {
17  return 2020102301;
18  }
19 
23  public function needsIncrementOffset(): bool {
24  return false;
25  }
26 
30  public function shouldBeSkipped(): bool {
31  return empty($this->countItems());
32  }
33 
37  public function countItems(): int {
38  $plugin = elgg_get_plugin_from_id('diagnostics');
39  if ($plugin instanceof \ElggPlugin) {
40  return 1;
41  }
42 
43  return 0;
44  }
45 
49  public function run(Result $result, $offset): Result {
50  $plugin = elgg_get_plugin_from_id('diagnostics');
51  if (!$plugin instanceof \ElggPlugin) {
52  $result->addSuccesses(1);
53  return $result;
54  }
55 
56  _elgg_services()->logger->disable();
57 
58  if ($plugin->delete()) {
59  $result->addSuccesses(1);
60  } else {
61  $result->addFailures(1);
62  }
63 
64  _elgg_services()->logger->enable();
65 
66  return $result;
67  }
68 }
$plugin
Plugin class containing helper functions for plugin activation/deactivation, dependency checking capa...
Definition: ElggPlugin.php:17
elgg_get_plugin_from_id(string $plugin_id)
Elgg plugins library Contains functions for managing plugins.
Definition: plugins.php:15
addFailures(int $num=1)
Increment failure count.
Definition: Result.php:53
if(empty($count)) $offset
Definition: pagination.php:26
addSuccesses(int $num=1)
Set an item (or items) as successfully upgraded.
Definition: Result.php:73
Result of a single BatchUpgrade run.
Definition: Result.php:10
Remove the diagnostics plugin entity.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:351
System upgrades are executed synchronously at system upgrade.