4

I have found the function rules_scheduler_schedule_task() under the rules module which supposedly does exactly what I want, but I have trouble interpreting how the function arguments are built. The arguments of that function are an array with the following keys :

  • config: The machine readable name of the to be scheduled component.
  • date: When the component should be executed.
  • identifier: User provided string to identify the task per scheduled

And finally :

  • state: A rules evaluation state to use for scheduling.

I don't have any trouble with the first three arguments, but what is the meaning of the later (state) ? Is it where I put the arguments of the components ? Could someone provide an example ?

6

I know this is an older post, but I had the same problem, and found this post. I found the answer so maybe someone can use it later:

$state = new RulesState();
$state->addVariable('variable_name', $variable, array());
// 3rd parameter is called $info it must be an array, but i don't know it's function

$task = array(
'identifier' => 'unique_id_of_scheduled_task',
'date' => time(), // timestamp
'config' => 'id_of_the_rule_component_to_run',
'state' => $state,
);

rules_scheduler_schedule_task($task);

So you have to create a RulesState object and pass in that in place of the 'state' parameter. I had to do this because in Rules I couldn't get the timestamp I wanted when I was configuring the "Schedule component evaluation" action.

1

The code for $State can be found in rules/includes/rules.states.inc. It looks like the class holds basic status information for a variety of conditions. Good hunting!

  • I did that hunting, but I need help in understanding the actual construction/content of that class. – drcelus Apr 23 '12 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.