X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FEvent%2FBAO%2FParticipantPayment.php;h=dc9dcfd12cc3aa93566e07ae0f5e28e8f15ea494;hb=a57505074ac550dabebfd9c374972aa4d6b71ed5;hp=2dbcd7033d0745e4ba7bf21c5d150ea754813bf0;hpb=d5e5f8438fe2777954f815731e1422c367624bea;p=civicrm-core.git diff --git a/CRM/Event/BAO/ParticipantPayment.php b/CRM/Event/BAO/ParticipantPayment.php index 2dbcd7033d..dc9dcfd12c 100644 --- a/CRM/Event/BAO/ParticipantPayment.php +++ b/CRM/Event/BAO/ParticipantPayment.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2018 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -29,7 +29,7 @@ * * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2018 * $Id$ * */ @@ -41,14 +41,15 @@ class CRM_Event_BAO_ParticipantPayment extends CRM_Event_DAO_ParticipantPayment * @param array $params * of values to initialize the record with. * @param array $ids - * with one values of id for this participantPayment record (for update). + * deprecated array. * * @return object * the partcipant payment record */ - public static function create(&$params, &$ids) { - if (isset($ids['id'])) { - CRM_Utils_Hook::pre('edit', 'ParticipantPayment', $ids['id'], $params); + public static function create(&$params, $ids = []) { + $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('id', $ids)); + if ($id) { + CRM_Utils_Hook::pre('edit', 'ParticipantPayment', $id, $params); } else { CRM_Utils_Hook::pre('create', 'ParticipantPayment', NULL, $params); @@ -56,16 +57,21 @@ class CRM_Event_BAO_ParticipantPayment extends CRM_Event_DAO_ParticipantPayment $participantPayment = new CRM_Event_BAO_ParticipantPayment(); $participantPayment->copyValues($params); - if (isset($ids['id'])) { - $participantPayment->id = CRM_Utils_Array::value('id', $ids); + if ($id) { + $participantPayment->id = $id; } else { $participantPayment->find(TRUE); } $participantPayment->save(); - if (isset($ids['id'])) { - CRM_Utils_Hook::post('edit', 'ParticipantPayment', $ids['id'], $participantPayment); + if (empty($participantPayment->contribution_id)) { + // For an id update contribution_id may be unknown. We want it + // further down so perhaps get it before the hooks. + $participantPayment->find(TRUE); + } + if ($id) { + CRM_Utils_Hook::post('edit', 'ParticipantPayment', $id, $participantPayment); } else { CRM_Utils_Hook::post('create', 'ParticipantPayment', NULL, $participantPayment);