function rules_scheduler_action_schedule

Base action implementation for scheduling components.

Related topics

1 string reference to 'rules_scheduler_action_schedule'
rules_scheduler_rules_action_info in rules_scheduler/rules_scheduler.rules.inc
Implements hook_rules_action_info().

File

rules_scheduler/rules_scheduler.rules.inc, line 76

Code

function rules_scheduler_action_schedule($args, $element) {
    $state = $args['state'];
    if ($component = rules_get_cache('comp_' . $args['component'])) {
        // Manually create a new evaluation state for scheduling the evaluation.
        $new_state = new RulesState();
        // Register all parameters as variables.
        foreach ($element->pluginParameterInfo() as $name => $info) {
            if (strpos($name, 'param_') === 0) {
                // Remove the parameter name prefix 'param_'.
                $var_name = substr($name, 6);
                $new_state->addVariable($var_name, $state->currentArguments[$name], $info);
            }
        }
        rules_scheduler_schedule_task(array(
            'date' => $args['date'],
            'config' => $args['component'],
            'data' => $new_state,
            'identifier' => $args['identifier'],
        ));
    }
    else {
        throw new RulesEvaluationException('Unable to get the component %name', array(
            '%name' => $args['component'],
        ), $element, RulesLog::ERROR);
    }
}