function services_client_process_mapping in Services Client 7
Process the mapping lists for fields
Parameters
object $src_data: This is the source data object. It is typically a $node or $user object
array $fields: This is the list of field mappings that were entered by the user
array $fields_empty: List of empty fields mapping
Return value
stdClass This is a resultant object with mapped elements that we will be sending to the destination services server.
3 calls to services_client_process_mapping()
- services_client_make_node_call in ./
services_client.module - Make the actual node create/update call for each connection and task
- services_client_make_submission_to_node_call in ./
services_client.module - Make the actual node create/update call for each connection and task
- services_client_make_user_call in ./
services_client.module - Make the actual user create/update call for each connection and task
File
- ./
services_client.module, line 880 - Services client module allows to push different types of objects on different types of events such as node_save, user_save to remote masters.
Code
function services_client_process_mapping($src_data, $fields, $fields_empty = array()) {
$data_obj = new stdClass();
// Loop through the fields and assign the data
foreach ($fields as $field) {
$field = trim($field);
if (!empty($field)) {
// Server is 0 and client is 1
list($server_name, $client_name) = explode('|', $field);
// Reset data
$data = NULL;
try {
// Map the client side object to its data
if ($client_name) {
$data = services_client_raw_data_get($client_name, $src_data);
}
// Map the server side object to its data
if ($server_name && (!empty($data) || $data === 0 || $data === "0" || $data === 0.0)) {
services_client_raw_data_set($server_name, $data_obj, $data);
}
} catch (ServicesClientDataNotFoundException $e) {
// Default empty is specified
if (isset($fields_empty[$client_name])) {
$server_name = isset($fields_empty[$client_name]['destination']) ? $fields_empty[$client_name]['destination'] : $server_name;
services_client_raw_data_set($server_name, $data_obj, $fields_empty[$client_name]['value']);
}
}
}
}
return $data_obj;
}