+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* @throws Exception
*/
public function getReportOutputAsCsv($reportClass, $inputParams) {
+
+ $reportObj = $this->getReportObject($reportClass, $inputParams);
+ try {
+ $rows = $reportObj->getResultSet();
+ $tmpFile = $this->createTempDir() . CRM_Utils_File::makeFileName('CiviReport.csv');
+ $csvContent = CRM_Report_Utils_Report::makeCsv($reportObj, $rows);
+ file_put_contents($tmpFile, $csvContent);
+ }
+ catch (Exception $e) {
+ throw $e;
+ }
+ return $tmpFile;
+ }
+
+ /**
+ * @param $reportClass
+ * @param array $inputParams
+ *
+ * @return array
+ * @throws Exception
+ */
+ public function getReportObject($reportClass, $inputParams) {
$config = CRM_Core_Config::singleton();
$config->keyDisable = TRUE;
$controller = new CRM_Core_Controller_Simple($reportClass, ts('some title'));
try {
$reportObj->storeResultSet();
$reportObj->buildForm();
- $rows = $reportObj->getResultSet();
-
- $tmpFile = $this->createTempDir() . CRM_Utils_File::makeFileName('CiviReport.csv');
- $csvContent = CRM_Report_Utils_Report::makeCsv($reportObj, $rows);
- file_put_contents($tmpFile, $csvContent);
}
catch (Exception $e) {
// print_r($e->getCause()->getUserInfo());
}
CRM_Utils_GlobalStack::singleton()->pop();
- return $tmpFile;
+ return $reportObj;
}
/**