You are here

function patterns_d2d_push_patterns_server in Patterns 7

Same name and namespace in other branches
  1. 7.2 patterns_d2d/includes/patterns_d2d.srpc.inc \patterns_d2d_push_patterns_server()
1 string reference to 'patterns_d2d_push_patterns_server'
patterns_d2d_drupaltodrupal_secure_rpc in patterns_d2d/includes/patterns_d2d.srpc.inc
Implements hook_drupaltodrupal_secure_rpc().

File

patterns_d2d/includes/patterns_d2d.srpc.inc, line 20
Code related to send pattern to server / receive pattern as server.

Code

function patterns_d2d_push_patterns_server($arguments, $rpc_info) {
  $imploded_patterns = $arguments['patterns'];
  $exploded_patterns = drupaltodrupal_explode($imploded_patterns);
  if ($exploded_patterns === FALSE) {
    throw new DrupalToDrupalRemoteException('internal error while processing patterns');
  }
  $n_patterns = 0;
  foreach ($exploded_patterns as $imploded_pattern) {
    $exploded_pattern = drupaltodrupal_explode($imploded_pattern);
    if ($exploded_pattern !== FALSE) {
      $check = array(
        'name' => 'is_string',
        'format' => 'is_string',
        'content' => 'is_string',
      );
      if (drupaltodrupal_check_array($exploded_pattern, $check)) {
        $name = $rpc_info['id'] . '_' . $exploded_pattern['name'];
        if (patterns_io_save_pattern($exploded_pattern['content'], $name, $exploded_pattern['format'])) {
          patterns_db_publish_pattern($name);
          $n_patterns++;
        }
      }
    }
  }
  return $n_patterns . ' pattern(s) received';
}