Merge pull request #17963 from civicrm/5.28
[civicrm-core.git] / CRM / Extension / Manager / Search.php
index d79e2472ae5ff98c8710f4efe6a650ace7cb93df..13ec3bca1eb42d1bfb7f5b7a9fbfc377d43f5e5c 100644 (file)
@@ -24,7 +24,10 @@ class CRM_Extension_Manager_Search extends CRM_Extension_Manager_Base {
    */
   public function __construct() {
     parent::__construct(TRUE);
-    $this->groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
+  }
+
+  public function getGroupId() {
+    return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
       self::CUSTOM_SEARCH_GROUP_NAME, 'id', 'name'
     );
   }
@@ -42,11 +45,11 @@ class CRM_Extension_Manager_Search extends CRM_Extension_Manager_Base {
     }
 
     $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue',
-      ['option_group_id' => $this->groupId]
+      ['option_group_id' => $this->getGroupId()]
     );
 
     $params = [
-      'option_group_id' => $this->groupId,
+      'option_group_id' => $this->getGroupId(),
       'weight' => $weight,
       'description' => $info->label . ' (' . $info->key . ')',
       'name' => $info->key,
@@ -69,12 +72,12 @@ class CRM_Extension_Manager_Search extends CRM_Extension_Manager_Base {
   public function onPreUninstall(CRM_Extension_Info $info) {
     $customSearchesByName = $this->getCustomSearchesByName();
     if (!array_key_exists($info->key, $customSearchesByName)) {
-      CRM_Core_Error::fatal('This custom search is not registered.');
+      throw new CRM_Core_Exception('This custom search is not registered.');
     }
 
     $cs = $this->getCustomSearchesById();
     $id = $cs[$customSearchesByName[$info->key]];
-    $optionValue = CRM_Core_BAO_OptionValue::del($id);
+    CRM_Core_BAO_OptionValue::del($id);
 
     return TRUE;
   }