Elgg  Version master
DeleteNotificationsPlugin.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 2021041901;
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('notifications');
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('notifications');
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
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
Remove the notifications plugin entity.
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
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
System upgrades are executed synchronously at system upgrade.