You are here

function cron_example_add_jobs_to_queue in Examples for Developers 7

Submit function used to add the items to the queue.

Related topics

1 string reference to 'cron_example_add_jobs_to_queue'
cron_example_form in cron_example/cron_example.module
The form to provide a link to cron.php.

File

cron_example/cron_example.module, line 147
Demonstrates use of the Cron API in Drupal - hook_cron()

Code

function cron_example_add_jobs_to_queue($form, &$form_state) {
  $queue = $form_state['values']['queue'];
  $num_items = $form_state['values']['num_items'];
  $queue = DrupalQueue::get($queue);
  for ($i = 1; $i <= $num_items; $i++) {
    $item = new stdClass();
    $item->created = time();
    $item->sequence = $i;
    $queue
      ->createItem($item);
  }
}