Merge pull request #16626 from pradpnayak/lineItemFixes
[civicrm-core.git] / CRM / Extension / Manager / Report.php
index eeba44919b7a1cf0d71116a793e8f39eeb63bf7a..bd8b5d67a7477e42bd72a32bba535506aa84af01 100644 (file)
@@ -32,12 +32,12 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base {
   /**
    * @param CRM_Extension_Info $info
    *
-   * @throws Exception
+   * @throws CRM_Core_Exception
    */
   public function onPreInstall(CRM_Extension_Info $info) {
     $customReports = $this->getCustomReportsByName();
     if (array_key_exists($info->key, $customReports)) {
-      CRM_Core_Error::fatal(ts('This report is already registered.'));
+      throw new CRM_Core_Exception(ts('This report is already registered.'));
     }
 
     if ($info->typeInfo['component'] === 'Contact') {
@@ -48,12 +48,11 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base {
       $compId = $comp->componentID;
     }
     if (empty($compId)) {
-      CRM_Core_Error::fatal(ts('Component for which you are trying to install the extension (%1) is currently disabled.', [1 => $info->typeInfo['component']]));
+      throw new CRM_Core_Exception(ts('Component for which you are trying to install the extension (%1) is currently disabled.', [1 => $info->typeInfo['component']]));
     }
     $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue',
       ['option_group_id' => $this->groupId]
     );
-    $ids = [];
     $params = [
       'label' => $info->label . ' (' . $info->key . ')',
       'value' => $info->typeInfo['reportUrl'],
@@ -65,7 +64,7 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base {
       'is_active' => 1,
     ];
 
-    $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
+    $optionValue = CRM_Core_BAO_OptionValue::add($params);
   }
 
   /**
@@ -74,11 +73,6 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base {
    * @return bool
    */
   public function onPreUninstall(CRM_Extension_Info $info) {
-
-    //        if( !array_key_exists( $info->key, $this->customReports ) ) {
-    //            CRM_Core_Error::fatal( 'This report is not registered.' );
-    //        }
-
     $customReports = $this->getCustomReportsByName();
     $cr = $this->getCustomReportsById();
     $id = $cr[$customReports[$info->key]];