$roleTypes = [];
foreach ($relType as $k => $v) {
- $roleTypes[substr($k, 0, strpos($k, '_'))] = $v;
+ //Limit this to relationship types from contact A to B
+ if (substr($k, -4) == "_a_b") {
+ $roleTypes[substr($k, 0, strpos($k, '_'))] = $v;
+ }
}
return $roleTypes;
}
/**
- * Get get list of relationship type based on the target contact type.
+ * Get list of relationship type based on the target contact type.
+ * Both directions of relationships are included if their labels are not the same.
*
* @param string $targetContactType
- * It's valid contact tpye(may be Individual , Organization , Household).
+ * A valid contact type (may be Individual, Organization, Household).
*
* @return array
- * array reference of all relationship types with context to current contact type .
+ * array reference of all relationship types with context to current contact type.
*/
public static function getRelationType($targetContactType) {
$relationshipType = [];
if ($type['contact_type_b'] == $targetContactType || empty($type['contact_type_b'])) {
$relationshipType[$key . '_a_b'] = $type['label_a_b'];
}
+ if (($type['contact_type_a'] == $targetContactType || empty($type['contact_type_a']))
+ && $type['label_a_b'] != $type['label_b_a']
+ ) {
+ $relationshipType[$key . '_b_a'] = $type['label_b_a'];
+ }
}
return $relationshipType;