private function WebformCivicrmPostProcess::saveRelationships in Webform CiviCRM Integration 8.5
Save relationships for a contact
Parameters
array $contact:
int $cid:
int $c:
1 call to WebformCivicrmPostProcess::saveRelationships()
- WebformCivicrmPostProcess::preSave in src/
WebformCivicrmPostProcess.php - Process webform submission when it is about to be saved. Called by the following hook:
File
- src/
WebformCivicrmPostProcess.php, line 1045 - Front-end form validation and post-processing.
Class
Namespace
Drupal\webform_civicrmCode
private function saveRelationships($contact, $cid, $c) {
// Process relationships
foreach (wf_crm_aval($contact, 'relationship', []) as $n => $params) {
$relationship_type_id = (array) wf_crm_aval($params, 'relationship_type_id');
// Expire un-selected relationships.
$field_key = "civicrm_{$c}_contact_{$n}_relationship_relationship_type_id";
$remove = array_keys($this
->getExposedOptions($field_key, (array) $params['relationship_type_id']));
if (!empty($remove)) {
$this
->expireRelationship($remove, $cid, $this->ent['contact'][$n]['id']);
}
// Create new relationships.
if (!empty($relationship_type_id)) {
foreach ($relationship_type_id as $params['relationship_type_id']) {
$this
->processRelationship($params, $cid, $this->ent['contact'][$n]['id']);
}
}
}
}