Elgg  Version 3.0
upgrade.php
Go to the documentation of this file.
1 <?php
11 
18  $pending = _elgg_services()->upgrades->getPendingUpgrades();
19  if (empty($pending)) {
20  elgg_delete_admin_notice('pending_upgrades');
21  }
22 }
23 
32 function _elgg_upgrade_entity_menu(\Elgg\Hook $hook) {
33 
34  $entity = $hook->getEntityParam();
35  if (!$entity instanceof ElggUpgrade || !$entity->canEdit()) {
36  return;
37  }
38 
39  $result = $hook->getValue();
40 
41  // deleting upgrades has no point, they'll be rediscovered again
42  // don't want to completely block the ability in ->canDelete(), just don't offer the link
43  $result->remove('delete');
44 
45  if (!$entity->isCompleted()) {
47  'name' => 'run_upgrade',
48  'icon' => 'play',
49  'text' => elgg_echo('admin:upgrades:menu:run_single'),
50  'href' => false,
51  'deps' => [
52  'core/js/upgrader',
53  ],
54  'data-guid' => $entity->guid,
55  ]);
56  } elseif ($batch = $entity->getBatch()) {
57  if (!$batch->shouldBeSkipped()) {
58  // only show reset if it will have an effect
60  'name' => 'reset',
61  'icon' => 'sync',
62  'text' => elgg_echo('reset'),
63  'href' => elgg_generate_action_url('admin/upgrade/reset', [
64  'guid' => $entity->guid,
65  ]),
66  ]);
67  }
68  }
69 
70  return $result;
71 }
72 
73 return function (\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
74  $events->registerHandler('complete', 'upgrade', '_elgg_upgrade_completed');
75 
76  $hooks->registerHandler('register', 'menu:entity', '_elgg_upgrade_entity_menu', 501);
77 };
elgg_delete_admin_notice($id)
Remove an admin notice by ID.
Definition: admin.php:71
elgg_generate_action_url($action, array $query=[], $add_csrf_tokens=true)
Generate an action URL.
Events service.
if(!$upgrade instanceof\ElggUpgrade) $result
Definition: upgrade.php:15
_elgg_upgrade_entity_menu(\Elgg\Hook $hook)
Add menu items to the entity menu of ElggUpgrade.
Definition: upgrade.php:32
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
static factory($options)
Create an ElggMenuItem from an associative array.
_elgg_upgrade_completed()
Perform some clean up when upgrade completes complete upgrade.
Definition: upgrade.php:17
Configuration exception.
Base class for events and hooks.
$entity
Definition: reset.php:8
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif(is_callable([$item, 'getType']))
Definition: item.php:39
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292