$contribution->id = $ids['contribution'];
$contribution->find();
+ if (empty($contribution->_component)) {
+ if (!empty($ids['event'])) {
+ $contribution->_component = 'event';
+ }
+ else {
+ $contribution->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
+ }
+ }
+
$contribution->loadRelatedObjects($input, $ids);
$memberships = $contribution->_relatedObjects['membership'] ?? [];
// 4) make ->_relatedObjects protected
// 5) hone up the individual functions to not use rely on this having been called
// 6) deprecate like mad
- if (empty($this->_component)) {
- if (!empty($ids['event'])) {
- $this->_component = 'event';
- }
- else {
- $this->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
- }
- }
-
- // If the object is not fully populated then make sure it is - this is a more about legacy paths & cautious
- // refactoring than anything else, and has unit test coverage.
- if (empty($this->financial_type_id)) {
- $this->find(TRUE);
- }
$paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $input, CRM_Utils_Array::value(
'paymentProcessor',
if (empty($ids['contact']) && isset($this->contact_id)) {
$ids['contact'] = $this->contact_id;
}
+
+ if (empty($this->_component)) {
+ if (!empty($ids['event'])) {
+ $this->_component = 'event';
+ }
+ else {
+ $this->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
+ }
+ }
+
+ // If the object is not fully populated then make sure it is - this is a more about legacy paths & cautious
+ // refactoring than anything else, and has unit test coverage.
+ if (empty($this->financial_type_id)) {
+ $this->find(TRUE);
+ }
$this->loadRelatedObjects($input, $ids);
if (empty($this->_component)) {
// and calls deprecated code. If we decide a contribution title is a
// 'real thing' then we should create a token.
$ids = array_merge(CRM_Contribute_BAO_Contribution::getComponentDetails($contributionID), $ids);
+
+ if (empty($contribution->_component)) {
+ if (!empty($ids['event'])) {
+ $contribution->_component = 'event';
+ }
+ else {
+ $contribution->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
+ }
+ }
+
$contribution->loadRelatedObjects($input, $ids);
$input['amount'] = $contribution->total_amount;
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $this->_contributionId;
$contribution->find(TRUE);
+ $contribution->_component = 'contribute';
$ids = array_merge(CRM_Contribute_BAO_Contribution::getComponentDetails($this->_contributionId), $this->ids);
$contribution->loadRelatedObjects($this->input, $ids);
$this->assertNotEmpty($contribution->_relatedObjects['membership']);