| 7 queue_example.module | queue_example_add_remove_form_claim($form, &$form_state) |
| 8 queue_example.module | queue_example_add_remove_form_claim($form, &$form_state) |
Submit function for the "claim" button. Claims (retrieves) an item from the queue and reports the results.
Related topics
1 string reference to 'queue_example_add_remove_form_claim'
File
- queue_example/
queue_example.module, line 161 - Examples demonstrating the Drupal Queue API.
Code
function queue_example_add_remove_form_claim($form, &$form_state) {
$queue = DrupalQueue::get($form_state['values']['queue_name']);
$queue->createQueue(); // There is no harm in trying to recreate existing.
$item = $queue->claimItem($form_state['values']['claim_time']);
$count = $queue->numberOfItems();
if (!empty($item)) {
drupal_set_message(t('Claimed item id=@item_id string=@string for @seconds seconds. There are @count items in the queue.', array('@count' => $count, '@item_id' => $item->item_id, '@string' => $item->data, '@seconds' => $form_state['values']['claim_time'])));
}
else {
drupal_set_message(t('There were no items in the queue available to claim. There are @count items in the queue.', array('@count' => $count)));
}
$form_state['rebuild'] = TRUE;
}
Login or register to post comments