function rules_action_data_convert_info_alter

Info alteration callback for variable add action.

Related topics

File

modules/data.eval.inc, line 245

Code

function rules_action_data_convert_info_alter(&$element_info, RulesAbstractPlugin $element) {
    if (isset($element->settings['type']) && ($type = $element->settings['type'])) {
        $element_info['provides']['conversion_result']['type'] = $type;
        // Only support the rounding behavior option for integers.
        if ($type == 'integer') {
            $element_info['parameter']['rounding_behavior'] = array(
                'type' => 'token',
                'label' => t('Rounding behavior'),
                'description' => t('The rounding behavior the conversion should use.'),
                'options list' => 'rules_action_data_convert_rounding_behavior_options',
                'restriction' => 'input',
                'default value' => 'round',
                'optional' => TRUE,
            );
        }
        else {
            unset($element_info['parameter']['rounding_behavior']);
        }
        // Configure compatible source-types:
        switch ($type) {
            case 'integer':
                $sources = array(
                    'decimal',
                    'text',
                    'token',
                    'uri',
                    'date',
                    'duration',
                    'boolean',
                );
                break;
            case 'decimal':
                $sources = array(
                    'integer',
                    'text',
                    'token',
                    'uri',
                    'date',
                    'duration',
                    'boolean',
                );
                break;
            case 'text':
                $sources = array(
                    'integer',
                    'decimal',
                    'token',
                    'uri',
                    'date',
                    'duration',
                    'boolean',
                );
                break;
            case 'token':
                $sources = array(
                    'integer',
                    'decimal',
                    'text',
                    'uri',
                    'date',
                    'duration',
                    'boolean',
                );
                break;
        }
        $element_info['parameter']['value']['type'] = $sources;
    }
}