Skip to content

Commit

Permalink
Temporarily switch to relationship::add function
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Feb 24, 2022
1 parent cc3ebd4 commit a4fd3fd
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions CRM/Case/XMLProcessor/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,20 @@ public function createRelationships($relationshipTypeXML, $params) {
];
}

\Civi\Api4\Relationship::save(FALSE)
->setRecords($relationshipValues)
->setMatch(['case_id', 'relationship_type_id', 'contact_id_a', 'contact_id_b'])
->execute();
//\Civi\Api4\Relationship::save(FALSE)
// ->setRecords($relationshipValues)
// ->setMatch(['case_id', 'relationship_type_id', 'contact_id_a', 'contact_id_b'])
// ->execute();
// FIXME: The above api code would be better, but doesn't work
// See discussion in https://github.com/civicrm/civicrm-core/pull/15030
foreach ($relationshipValues as $params) {
$dao = new CRM_Contact_DAO_Relationship();
$dao->copyValues($params);
// only create a relationship if it does not exist
if (!$dao->find(TRUE)) {
CRM_Contact_BAO_Relationship::add($params);
}
}

return TRUE;
}
Expand Down

0 comments on commit a4fd3fd

Please sign in to comment.