You are here

function wsclient_rules_data_info in Web service client 7

Implements hook_rules_data_info().

File

./wsclient.rules.inc, line 11
Web service client - Rules integration.

Code

function wsclient_rules_data_info() {
  $types = array();

  // Collect all data types of all services.
  $all_types = array();
  foreach (entity_load_multiple_by_name('wsclient_service', FALSE) as $name => $service) {
    foreach ($service
      ->dataTypes() as $type => $type_info) {

      // Prefix the label with the service label.
      $type_info['label'] = $service->label . ': ' . $type_info['label'];
      $all_types['wsclient_' . $name . '_' . $type] = $type_info;
    }
  }

  // Prepare data type info for Rules.
  foreach ($all_types as $type => $type_info) {
    wsclient_type_info_populate($type_info, $type_info['service'], $all_types);
    $type_info = array_intersect_key($type_info, array_flip(array(
      'label',
      'property info',
    ))) + array(
      'wrap' => TRUE,
      'creation callback' => 'rules_action_data_create_array',
    );
    $types[$type] = $type_info;
  }
  return $types;
}