From 67cb5b15ebefe70c36b43c41070812aa77e18c66 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 28 Dec 2016 19:04:38 +0530 Subject: [PATCH] CRM-19804, added pre and post hook invokation for FinancialAccount ---------------------------------------- * CRM-19804: Pre() and Post() hook for Financial Account https://issues.civicrm.org/jira/browse/CRM-19804 --- CRM/Financial/BAO/FinancialAccount.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index e1db8915aa8c..7a3bf8debb8d 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -112,6 +112,14 @@ public static function add(&$params) { // action is taken depending upon the mode $financialAccount = new CRM_Financial_DAO_FinancialAccount(); + + // invoke pre hook + $op = 'create'; + if (!empty($params['id'])) { + $op = 'edit'; + } + CRM_Utils_Hook::pre($op, 'FinancialAccount', CRM_Utils_Array::value('id', $params), $params); + if (!empty($params['id'])) { $financialAccount->id = $params['id']; $financialAccount->find(TRUE); @@ -128,6 +136,14 @@ public static function add(&$params) { $financialAccount->opening_balance = $financialAccount->current_period_opening_balance = '0.00'; } $financialAccount->save(); + + // invoke post hook + $op = 'create'; + if (!empty($params['id'])) { + $op = 'edit'; + } + CRM_Utils_Hook::post($op, 'FinancialAccount', $financialAccount->id, $financialAccount); + return $financialAccount; }