You are here

function services_client_make_node_delete_call in Services Client 7

Delete node on remote site.

1 call to services_client_make_node_delete_call()
services_client_make_call in ./services_client.module
Make call to remote site by event $type

File

./services_client.module, line 770
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_make_node_delete_call($node, $task) {

  // Generate our connection object. If false, then we failed login.
  $client = services_client_connection_get($task->conn_name);
  watchdog('sc_node', 'Deleting node @title - @nid from %conn', array(
    '%conn' => $task->conn_name,
    '@title' => $node->title,
    '@nid' => $node->nid,
  ));

  // Find out if there is already an object on the master server with this UUID
  $nid = services_client_scalar_result($client
    ->get('uuid', 'node', array(
    'uuid' => $node->uuid,
  )));
  if ($nid) {

    // Delete remote node
    $client
      ->delete('node', $nid);
    watchdog('sc_node', 'Node @nid was deleted from remote site @name', array(
      '@nid' => $node->nid,
      '@name' => $task->conn_name,
    ));
  }
  else {
    watchdog('sc_node', 'Node @nid was not found on remote site @name', array(
      '@nid' => $node->nid,
      '@name' => $task->conn_name,
    ));
  }
}