Skip to content

Commit

Permalink
CRM-19804, added pre and post hook invokation for FinancialAccount
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-19804: Pre() and Post() hook for Financial Account
  https://issues.civicrm.org/jira/browse/CRM-19804
  • Loading branch information
pradpnayak committed Dec 28, 2016
1 parent 4e098b3 commit 67cb5b1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CRM/Financial/BAO/FinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit 67cb5b1

Please sign in to comment.