You are here

function rules_action_data_create_info_alter in Rules 7.2

Info alteration callback for data create action.

Related topics

File

modules/data.eval.inc, line 316
Contains rules integration for the data module needed during evaluation.

Code

function rules_action_data_create_info_alter(&$element_info, RulesAbstractPlugin $element) {
  if (!empty($element->settings['type'])) {
    $type = $element->settings['type'];
    $cache = rules_get_cache();
    $type_info = $cache['data_info'][$type];
    if (isset($type_info['property info'])) {

      // Add the data type's properties as parameters.
      foreach ($type_info['property info'] as $property => $property_info) {

        // Prefix parameter names to avoid name clashes with
        // existing parameters.
        $element_info['parameter']['param_' . $property] = array_intersect_key($property_info, array_flip(array(
          'type',
          'label',
          'allow null',
        )));
        if (empty($property_info['required'])) {
          $element_info['parameter']['param_' . $property]['optional'] = TRUE;
          $element_info['parameter']['param_' . $property]['allow null'] = TRUE;
        }
      }
    }
    $element_info['provides']['data_created']['type'] = $type;
  }
}