Commit | Line | Data |
---|---|---|
4b644b84 | 1 | <?php |
5e4accea | 2 | use CRM_AfformAdmin_ExtensionUtil as E; |
4b644b84 TO |
3 | |
4 | /** | |
5 | * Collection of upgrade steps. | |
6 | */ | |
5e4accea | 7 | class CRM_AfformAdmin_Upgrader extends CRM_AfformAdmin_Upgrader_Base { |
4b644b84 TO |
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 | /** | |
5e04a2d4 CW |
13 | * Setup navigation item on new installs. |
14 | * | |
5e4accea | 15 | * Note: this path is not in the menu.xml because routing is handled by afform |
ce8b6957 | 16 | */ |
4b644b84 | 17 | public function install() { |
ce8b6957 TO |
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', | |
be47f409 | 26 | 'label' => ts('Forms'), |
ce8b6957 TO |
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 | } | |
4b644b84 TO |
38 | } |
39 | ||
40 | /** | |
0372843b | 41 | * Cleanup navigation upon removal |
ce8b6957 | 42 | */ |
4b644b84 | 43 | public function uninstall() { |
ce8b6957 TO |
44 | civicrm_api3('Navigation', 'get', [ |
45 | 'name' => 'afform_gui', | |
46 | 'return' => ['id'], | |
47 | 'api.Navigation.delete' => [], | |
48 | ]); | |
4b644b84 TO |
49 | } |
50 | ||
4b644b84 | 51 | } |