You are here

function rules_action_data_calc_info_alter in Rules 7.2

Info alter callback for the data_calc action.

Related topics

File

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

Code

function rules_action_data_calc_info_alter(&$element_info, RulesPlugin $element) {
  if ($info = $element
    ->getArgumentInfo('input_1')) {

    // Only allow durations as offset for date values.
    if ($info['type'] == 'date') {
      $element_info['parameter']['input_2']['type'] = 'duration';
    }

    // Specify the data type of the result.
    $element_info['provides']['result']['type'] = $info['type'];
    if ($info['type'] == 'integer' && ($info2 = $element
      ->getArgumentInfo('input_2')) && $info2['type'] == 'decimal') {
      $element_info['provides']['result']['type'] = 'decimal';
    }
    elseif (isset($element->settings['op']) && $element->settings['op'] == '/') {
      $element_info['provides']['result']['type'] = 'decimal';
    }
  }
}