/**
* This function exists to wrap api getValue function & check the result
- * so we can ensure they succeed & throw exceptions without litterering the test with checks
+ * so we can ensure they succeed & throw exceptions without littering the test with checks
* There is a type check in this
*
* @param string $entity
public function callAPISuccessGetValue($entity, $params, $type = NULL) {
$params += [
'version' => $this->_apiversion,
- 'debug' => 1,
];
$result = $this->civicrm_api($entity, 'getvalue', $params);
if (is_array($result) && (!empty($result['is_error']) || isset($result['values']))) {
$v4Params['select'][] = 'id';
}
// Convert join syntax
- foreach ($v4Params['select'] as &$select) {
+ foreach ($v4Params['select'] as $idx => $select) {
if (strstr($select, '_id.')) {
- $joins[$select] = explode('.', str_replace('_id.', '.', $select));
- $select = str_replace('_id.', '.', $select);
+ $joins[$select] = $v4Params['select'][$idx] = str_replace('_id.', '.', $select);
}
}
}
$result[$index][$key] = $this->runApi4LegacyChain($key, $params, $v4Entity, $row, $sequential);
}
// Convert join format
- foreach ($joins as $api3Key => $api4Path) {
- $result[$index][$api3Key] = \CRM_Utils_Array::pathGet($result[$index], $api4Path);
+ foreach ($joins as $api3Key => $api4Key) {
+ $result[$index][$api3Key] = $result[$index][$api4Key] ?? NULL;
}
// Resolve custom field names
foreach ($custom as $group => $fields) {