function Utils::wf_crm_get_contact_relationship_types in Webform CiviCRM Integration 8.5
Get valid relationship types for a given pair of contacts
Parameters
$type_a: Contact type
$type_b: Contact type
$sub_type_a: Contact sub-type
$sub_type_b: Contact sub-type
Return value
array
Overrides UtilsInterface::wf_crm_get_contact_relationship_types
File
- src/
Utils.php, line 389 - Webform CiviCRM module's common utility functions.
Class
Namespace
Drupal\webform_civicrmCode
function wf_crm_get_contact_relationship_types($type_a, $type_b, $sub_type_a, $sub_type_b) {
$ret = [];
foreach ($this
->wf_crm_get_relationship_types() as $t) {
$reciprocal = $t['label_a_b'] != $t['label_b_a'] && $t['label_b_a'] || $t['type_a'] != $t['type_b'];
if (($t['type_a'] == $type_a || !$t['type_a']) && ($t['type_b'] == $type_b || !$t['type_b']) && (in_array($t['sub_type_a'], $sub_type_a) || !$t['sub_type_a']) && (in_array($t['sub_type_b'], $sub_type_b) || !$t['sub_type_b'])) {
$ret[$t['id'] . ($reciprocal ? '_a' : '_r')] = $t['label_a_b'];
}
// Reciprocal form - only show if different from above
if ($reciprocal && ($t['type_a'] == $type_b || !$t['type_a']) && ($t['type_b'] == $type_a || !$t['type_b']) && (in_array($t['sub_type_a'], $sub_type_b) || !$t['sub_type_a']) && (in_array($t['sub_type_b'], $sub_type_a) || !$t['sub_type_b'])) {
$ret[$t['id'] . '_b'] = $t['label_b_a'];
}
}
return $ret;
}