Skip to content

Commit

Permalink
Merge pull request #9584 from JMAConsulting/CRM-19804
Browse files Browse the repository at this point in the history
[ready-for-core-team-review]CRM-19804, added pre and post hook invokation for FinancialAccount
  • Loading branch information
monishdeb authored Dec 30, 2016
2 parents d96ee4e + afa09af commit f859f6b
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 f859f6b

Please sign in to comment.