You are here

function wsclient_type_info_populate in Web service client 7

Helper function to recursively populate property information in a data type information array. Also adds a default label from the machine name.

Parameters

$type_info: Type information array that describes the type.

$service_name: The name of the web service description where the type information belongs to.

$all_types: Array of all data types of all web service descriptions.

unknown_type $recursion_stop: Array of data type names that have already been used to populate property information. Used to prevent endless recursion.

1 call to wsclient_type_info_populate()
wsclient_rules_data_info in ./wsclient.rules.inc
Implements hook_rules_data_info().

File

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

Code

function wsclient_type_info_populate(array &$type_info, $service_name, array $all_types, $recursion_stop = array()) {
  if (isset($type_info['property info'])) {
    foreach ($type_info['property info'] as $name => &$info) {
      if (!isset($info['label']) || $info['label'] == '') {
        $info['label'] = $name;
      }

      // Get the global type name.
      $type = wsclient_global_type_name($info['type'], $service_name, $all_types);

      // Date values are converted from ISO strings to timestamp, if needed.
      if ($type == 'date') {
        $info['getter callback'] = 'entity_property_verbatim_date_get';
      }

      // Copy recursion information for this property.
      $new_recursion_stop = $recursion_stop;
      if (!isset($info['property info']) && isset($all_types[$type]) && !isset($recursion_stop[$type])) {
        $info['type'] = strpos($info['type'], 'list<') === 0 ? 'list<' . $type . '>' : $type;

        // Copy over the property information.
        $info['property info'] = $all_types[$type]['property info'];

        // Mark this type as finished.
        $new_recursion_stop[$type] = TRUE;
      }

      // Also populate nested property info arrays (recursion).
      wsclient_type_info_populate($info, $service_name, $all_types, $new_recursion_stop);
    }
  }
}