+ if (empty($line['entity_id'])) {
+ $line['entity_id'] = $entityId;
+ }
+ if(!empty($line['membership_type_id'])) {
+ $line['entity_table'] = 'civicrm_membership';
+ }
+ if (!empty($contributionDetails->id)) {
+ $line['contribution_id'] = $contributionDetails->id;
+ if ($line['entity_table'] == 'civicrm_contribution') {
+ $line['entity_id'] = $contributionDetails->id;
+ }
+ }
+