* @static
*/
static function create(&$params) {
- //create mode only as we don't support editing line items
-
- CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
+ $id = CRM_Utils_Array::value('id', $params);
+ if ($id) {
+ CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params);
+ }
+ else {
+ CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
+ }
+
+ // unset entity table and entity id in $params
+ // we never update the entity table and entity id during update mode
+ if ($id) {
+ unset($params['entity_id'], $params['entity_table']);
+ }
$lineItemBAO = new CRM_Price_BAO_LineItem();
$lineItemBAO->copyValues($params);
$return = $lineItemBAO->save();
- CRM_Utils_Hook::post('create', 'LineItem', $params['entity_id'], $params);
+ if ($id) {
+ CRM_Utils_Hook::post('edit', 'LineItem', $id, $params);
+ }
+ else {
+ CRM_Utils_Hook::post('create', 'LineItem', $params['entity_id'], $params);
+ }
return $return;
}