function rules_scheduler_schedule_task

Schedule a task to be executed later on.

Parameters

array $task: An array representing the task with the following keys:

  • config: The machine readable name of the to-be-scheduled component.
  • date: Timestamp when the component should be executed.
  • state: (deprecated) Rules evaluation state to use for scheduling.
  • data: Any additional data to store with the task.
  • handler: The name of the task handler class.
  • identifier: User provided string to identify the task per scheduled

configuration.

2 calls to rules_scheduler_schedule_task()
RulesSchedulerTestCase::testCustomTaskHandler in rules_scheduler/tests/rules_scheduler.test
Tests that custom task handlers are properly invoked.
rules_scheduler_action_schedule in rules_scheduler/rules_scheduler.rules.inc
Base action implementation for scheduling components.

File

rules_scheduler/rules_scheduler.module, line 158

Code

function rules_scheduler_schedule_task($task) {
    // Map the deprecated 'state' property into 'data'.
    if (isset($task['state'])) {
        $task['data'] = $task['state'];
        unset($task['state']);
    }
    if (!empty($task['identifier'])) {
        // If there is a task with the same identifier and component, we replace it.
        db_delete('rules_scheduler')->condition('config', $task['config'])
            ->condition('identifier', $task['identifier'])
            ->execute();
    }
    drupal_write_record('rules_scheduler', $task);
}