- if (is_a($objects['contribution'], 'CRM_Contribute_BAO_Contribution')) {
- $contribution = &$objects['contribution'];
- }
- else {
- //legacy support - functions are 'used' to be able to pass in a DAO
- $contribution = new CRM_Contribute_BAO_Contribution();
- $contribution->id = $ids['contribution'] ?? NULL;
- $contribution->find(TRUE);
- $objects['contribution'] = &$contribution;
- }
- try {
- $success = $contribution->loadRelatedObjects($input, $ids);
- if ($required && empty($contribution->_relatedObjects['paymentProcessor'])) {
- throw new CRM_Core_Exception("Could not find payment processor for contribution record: " . $contribution->id);
- }
- }
- catch (Exception $e) {
- $success = FALSE;
- if (!empty($error_handling['log_error'])) {
- CRM_Core_Error::debug_log_message($e->getMessage());
- }
- if (!empty($error_handling['echo_error'])) {
- echo $e->getMessage();
- }
- if (!empty($error_handling['return_error'])) {
- return [
- 'is_error' => 1,
- 'error_message' => ($e->getMessage()),
- ];
- }
+ $success = $contribution->loadRelatedObjects($input, $ids);
+ if ($required && empty($contribution->_relatedObjects['paymentProcessor'])) {
+ throw new CRM_Core_Exception("Could not find payment processor for contribution record: " . $contribution->id);