Rename afform_gui -> afform_admin
[civicrm-core.git] / ext / afform / admin / CRM / AfformAdmin / Upgrader.php
1 <?php
2 use CRM_AfformAdmin_ExtensionUtil as E;
3
4 /**
5 * Collection of upgrade steps.
6 */
7 class CRM_AfformAdmin_Upgrader extends CRM_AfformAdmin_Upgrader_Base {
8
9 // By convention, functions that look like "function upgrade_NNNN()" are
10 // upgrade tasks. They are executed in order (like Drupal's hook_update_N).
11
12 /**
13 * Setup navigation item on new installs.
14 *
15 * Note: this path is not in the menu.xml because routing is handled by afform
16 */
17 public function install() {
18 try {
19 $existing = civicrm_api3('Navigation', 'getcount', [
20 'name' => 'afform_gui',
21 'domain_id' => CRM_Core_Config::domainID(),
22 ]);
23 if (!$existing) {
24 civicrm_api3('Navigation', 'create', [
25 'parent_id' => 'Customize Data and Screens',
26 'label' => ts('Forms'),
27 'weight' => 1,
28 'name' => 'afform_gui',
29 'permission' => 'administer CiviCRM',
30 'url' => 'civicrm/admin/afform',
31 'is_active' => 1,
32 ]);
33 }
34 }
35 catch (Exception $e) {
36 // Couldn't create menu item.
37 }
38 }
39
40 /**
41 * Cleanup navigation upon removal
42 */
43 public function uninstall() {
44 civicrm_api3('Navigation', 'get', [
45 'name' => 'afform_gui',
46 'return' => ['id'],
47 'api.Navigation.delete' => [],
48 ]);
49 }
50
51 }