$this->loadRelatedObjects($paymentProcessorID, $ids);
$paymentProcessor = $this->_relatedObjects['paymentProcessor'] ?? NULL;
+ $eventID = isset($ids['event']) ? (int) $ids['event'] : NULL;
+ $participantID = isset($ids['participant']) ? (int) $ids['participant'] : NULL;
//not really sure what params might be passed in but lets merge em into values
- $values = array_merge($this->_gatherMessageValues($input, $values, $ids), $values);
+ $values = array_merge($this->_gatherMessageValues($values, $eventID, $participantID), $values);
$values['is_email_receipt'] = !$returnMessageText;
foreach (['receipt_date', 'cc_receipt', 'bcc_receipt', 'receipt_from_name', 'receipt_from_email', 'receipt_text', 'pay_later_receipt'] as $fld) {
if (!empty($input[$fld])) {
}
if ($this->_component === 'event') {
- $eventID = $this->_relatedObjects['participant']->event_id;
$eventParams = ['id' => $eventID];
$values['event'] = [];
}
return CRM_Event_BAO_Event::sendMail($ids['contact'], $values,
- $this->_relatedObjects['participant']->id, $this->is_test, $returnMessageText
+ $participantID, $this->is_test, $returnMessageText
);
}
else {
* as part of CRM-9996 refactoring as a step towards simplifying the composeMessage function
* Values related to the contribution in question are gathered
*
- * @param array $input
- * Input into function (probably from payment processor).
* @param array $values
- * @param array $ids
- * The set of ids related to the input.
+ * @param int|null $eventID
+ * @param int|null $participantID
*
* @return array
* @throws \CRM_Core_Exception
*/
- public function _gatherMessageValues($input, &$values, $ids = []) {
+ public function _gatherMessageValues($values, ?int $eventID, ?int $participantID) {
// set display address of contributor
$values['billingName'] = '';
if ($this->address_id) {
);
// if this is onbehalf of contribution then set related contact
if (!empty($relatedContact['individual_id'])) {
- $values['related_contact'] = $ids['related_contact'] = $relatedContact['individual_id'];
+ $values['related_contact'] = $relatedContact['individual_id'];
}
}
else {
- $values = array_merge($values, $this->loadEventMessageTemplateParams((int) $ids['event'], (int) $this->_relatedObjects['participant']->id, $this->id));
+ $values = array_merge($values, $this->loadEventMessageTemplateParams($eventID, $participantID, $this->id));
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', NULL, $this->id);
'receipt_from_email' => 'donationFake@civicrm.org',
'contribution_status' => 'Completed',
];
- $gathered_values = $contribution_bao->_gatherMessageValues(
- [
- 'payment_processor_id' => $payment_processor['id'],
- 'is_email_receipt' => TRUE,
- ],
- $values,
- [
- 'component' => 'contribute',
- 'contact_id' => $contact_contributor,
- 'contact' => $contact_contributor,
- 'financialType' => $contribution['values'][$contribution['id']]['financial_type_id'],
- 'contributionType' => $contribution['values'][$contribution['id']]['contribution_type_id'],
- 'contributionPage' => $contributionPage['id'],
- 'membership' => [],
- 'paymentProcessor' => $payment_processor['id'],
- 'contribution' => $contribution['id'],
- ]
- );
+ $gathered_values = $contribution_bao->_gatherMessageValues($values, NULL, NULL);
$this->assertEquals([
'receipt_from_name' => 'CiviCRM Fundraising Dept.',