Skip to content

Commit

Permalink
Merge pull request #15076 from sushantpaste/priceset-hook
Browse files Browse the repository at this point in the history
dev/core#870 priceset hook
  • Loading branch information
eileenmcnaughton authored Aug 19, 2019
2 parents ea5213c + 214d5f5 commit 4a26613
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CRM/Price/BAO/PriceField.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField {
* @return CRM_Price_BAO_PriceField
*/
public static function add(&$params) {
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'PriceField', CRM_Utils_Array::value('id', $params), $params);

$priceFieldBAO = new CRM_Price_BAO_PriceField();

$priceFieldBAO->copyValues($params);
Expand All @@ -70,6 +73,7 @@ public static function add(&$params) {
}

$priceFieldBAO->save();
CRM_Utils_Hook::post($hook, 'PriceField', $priceFieldBAO->id, $priceFieldBAO);
return $priceFieldBAO;
}

Expand Down
4 changes: 4 additions & 0 deletions CRM/Price/BAO/PriceFieldValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue {
* @return CRM_Price_DAO_PriceFieldValue
*/
public static function add(&$params, $ids = []) {
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'PriceFieldValue', CRM_Utils_Array::value('id', $params), $params);

$fieldValueBAO = new CRM_Price_BAO_PriceFieldValue();
$fieldValueBAO->copyValues($params);
Expand All @@ -71,6 +73,8 @@ public static function add(&$params, $ids = []) {
}

$fieldValueBAO->save();
CRM_Utils_Hook::post($hook, 'PriceFieldValue', $fieldValueBAO->id, $fieldValueBAO);

// Reset the cached values in this function.
CRM_Price_BAO_PriceField::getOptions(CRM_Utils_Array::value('price_field_id', $params), FALSE, TRUE);
return $fieldValueBAO;
Expand Down
8 changes: 7 additions & 1 deletion CRM/Price/BAO/PriceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function __construct() {
* @return CRM_Price_DAO_PriceSet
*/
public static function create(&$params) {
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'PriceSet', CRM_Utils_Array::value('id', $params), $params);

if (empty($params['id']) && empty($params['name'])) {
$params['name'] = CRM_Utils_String::munge($params['title'], '_', 242);
}
Expand All @@ -81,7 +84,10 @@ public static function create(&$params) {
if (self::eventPriceSetDomainID()) {
$priceSetBAO->domain_id = CRM_Core_Config::domainID();
}
return $priceSetBAO->save();
$priceSetBAO->save();

CRM_Utils_Hook::post($hook, 'PriceSet', $priceSetBAO->id, $priceSetBAO);
return $priceSetBAO;
}

/**
Expand Down

0 comments on commit 4a26613

Please sign in to comment.