You are here

function services_resources_as_procedures in Services 6.3

Same name and namespace in other branches
  1. 7.3 services.module \services_resources_as_procedures()

Convert a resource to RPC-style methods.

Parameters

array $resource: A resource definition.

string $resource_name: The resource name, ie: node.

Return value

array An array of RPC method definitions

1 call to services_resources_as_procedures()
xmlrpc_server_xmlrpc in servers/xmlrpc_server/xmlrpc_server.module
Return an array of all defined services methods and callbacks.

File

./services.module, line 464
Provides a generic but powerful API for web services.

Code

function services_resources_as_procedures($resource, $resource_name) {
  $methods = array();
  $class_info = services_operation_class_info();
  foreach ($class_info as $class_name => $class) {
    if (empty($resource[$class_name])) {
      continue;
    }
    foreach ($resource[$class_name] as $op_name => $op) {
      $method_name = "{$resource_name}.{$op_name}";
      if (empty($methods[$method_name])) {
        $methods[$method_name] = array(
          'method' => $method_name,
        ) + $op;
      }
      else {
        watchdog('services', 'Naming collision when listing controllers as methods. The %class %operation wont be available for RPC-style servers.', array(
          '%class' => $class['name'],
          '%operation' => $op_name,
        ), WATCHDOG_WARNING);
      }
    }
  }
  return $methods;
}