You are here

function services_client_type_override in Services Client 7

Do node->type override mapping

Parameters

array $types: A list of type mappings separated by pipe.

string $node_type: The node's current type.

Return value

string A new (or the same if no match was found) type for this node.

2 calls to services_client_type_override()
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

File

./services_client.module, line 1040
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_type_override($types, $node_type) {

  // Set the assigned type to the existing
  $assigned_type = $node_type;

  // Loop through the type list.
  foreach ($types as $type) {

    // Server is 0 and client is 1
    $mpair = explode('|', $type);
    $mname = trim($mpair[0]);
    $cname = trim($mpair[1]);

    // If we find an entry that matches the current node's type then we assign the master type to it.
    if ($node_type == $cname) {
      $assigned_type = $mname;
      break;

      // there can only be one node type mapping per node, so we'll break out of this foreach;
    }
  }

  // Return our assigned type. If we didn't get a match, it will be the original.
  return $assigned_type;
}