+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2018
* $Id$
*
*/
* @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);
$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);