Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21803 Fix another entity to be standardised & support custom data #11718

Merged
merged 1 commit into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions CRM/Event/BAO/ParticipantPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,37 @@ 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);
}

$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);
Expand Down
3 changes: 1 addition & 2 deletions CRM/Event/Cart/Form/Checkout/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public function registerParticipant($params, &$participant, $event) {
'participant_id' => $participant->id,
'contribution_id' => $params['contributionID'],
);
$ids = array();
CRM_Event_BAO_ParticipantPayment::create($payment_params, $ids);
CRM_Event_BAO_ParticipantPayment::create($payment_params);
}

$transaction->commit();
Expand Down
3 changes: 1 addition & 2 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1308,9 +1308,8 @@ public function submit($params) {
'participant_id' => $participants[0]->id,
'contribution_id' => $contribution->id,
);
$ids = array();

CRM_Event_BAO_ParticipantPayment::create($paymentParticipant, $ids);
CRM_Event_BAO_ParticipantPayment::create($paymentParticipant);
$this->_contactIds[] = $this->_contactId;
}
else {
Expand Down
3 changes: 1 addition & 2 deletions CRM/Event/Form/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,7 @@ public function confirmPostProcess($contactID = NULL, $contribution = NULL, $pay
'participant_id' => $participant->id,
'contribution_id' => $contribution->id,
);
$ids = array();
$paymentPartcipant = CRM_Event_BAO_ParticipantPayment::create($paymentParams, $ids);
$paymentPartcipant = CRM_Event_BAO_ParticipantPayment::create($paymentParams);
}

//set only primary participant's params for transfer checkout.
Expand Down
12 changes: 1 addition & 11 deletions api/v3/ParticipantPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,7 @@
* @return array
*/
function civicrm_api3_participant_payment_create($params) {

$ids = array();
if (!empty($params['id'])) {
$ids['id'] = $params['id'];
}
$participantPayment = CRM_Event_BAO_ParticipantPayment::create($params, $ids);

$payment = array();
_civicrm_api3_object_to_array($participantPayment, $payment[$participantPayment->id]);

return civicrm_api3_create_success($payment, $params);
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ParticipantPayment');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,7 @@ public function addParticipantWithContribution() {
'participant_id' => $participant->id,
'contribution_id' => $contribution['id'],
);
$ids = array();
CRM_Event_BAO_ParticipantPayment::create($paymentParticipant, $ids);
CRM_Event_BAO_ParticipantPayment::create($paymentParticipant);

$contributionObject = new CRM_Contribute_BAO_Contribution();
$contributionObject->id = $contribution['id'];
Expand Down
4 changes: 0 additions & 4 deletions tests/phpunit/api/v3/SyntaxConformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,13 @@ public static function toBeSkipped_custom_data_creatable($sequential = FALSE) {
'UFJoin',
'UFField',
'PriceFieldValue',
'Website',
'JobLog',
'GroupContact',
'EntityTag',
'PledgePayment',
'PaymentProcessorType',
'Relationship',
'RelationshipType',
'ParticipantPayment',

// ones that are not real entities hence not extendable.
'ActivityType',
Expand Down Expand Up @@ -466,7 +464,6 @@ public static function toBeSkipped_automock($sequential = FALSE) {
'MailingContact',
'EntityTag',
'Participant',
'ParticipantPayment',
'Setting',
'SurveyRespondant',
'MailingRecipients',
Expand Down Expand Up @@ -535,7 +532,6 @@ public static function toBeSkipped_updatesingle($sequential = FALSE) {
'GroupContact',
'MembershipPayment',
'Participant',
'ParticipantPayment',
'LineItem',
'PledgePayment',
'ContributionPage',
Expand Down