From b6a8040140c694ed89752ae2af7639e4f3d9d82a Mon Sep 17 00:00:00 2001 From: Johan Vervloet Date: Mon, 30 May 2016 20:54:21 +0200 Subject: [PATCH] CRM-18697 - Move specific output implementations to appropriate classes. ---------------------------------------- * CRM-18697: Make it possible to add new ExportFormats via extensions https://issues.civicrm.org/jira/browse/CRM-18697 --- CRM/Financial/BAO/ExportFormat.php | 18 +++++------------- CRM/Financial/BAO/ExportFormat/IIF.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CRM/Financial/BAO/ExportFormat.php b/CRM/Financial/BAO/ExportFormat.php index 5cc800f6ff..ad6dfcf9d2 100644 --- a/CRM/Financial/BAO/ExportFormat.php +++ b/CRM/Financial/BAO/ExportFormat.php @@ -71,21 +71,13 @@ abstract class CRM_Financial_BAO_ExportFormat { } /** - * @param null $fileName + * Exports sbatches in $this->_batchIds, and saves to file. + * + * @param string $fileName - use this file name (if applicable) */ public function output($fileName = NULL) { - switch ($this->getFileExtension()) { - case 'csv': - self::createActivityExport($this->_batchIds, $fileName); - break; - - case 'iif': - $tplFile = $this->getHookedTemplateFileName(); - $out = self::getTemplate()->fetch($tplFile); - $fileName = $this->putFile($out); - self::createActivityExport($this->_batchIds, $fileName); - break; - } + // Default behaviour, override if needed: + self::createActivityExport($this->_batchIds, $fileName); } /** diff --git a/CRM/Financial/BAO/ExportFormat/IIF.php b/CRM/Financial/BAO/ExportFormat/IIF.php index 65a3795dc7..88e42f3176 100644 --- a/CRM/Financial/BAO/ExportFormat/IIF.php +++ b/CRM/Financial/BAO/ExportFormat/IIF.php @@ -78,6 +78,16 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat $this->output(); } + /** + * @param null $fileName + */ + public function output($fileName = NULL) { + $tplFile = $this->getHookedTemplateFileName(); + $out = self::getTemplate()->fetch($tplFile); + $fileName = $this->putFile($out); + self::createActivityExport($this->_batchIds, $fileName); + } + /** * @param $out * -- 2.25.1