function queue_example_add_remove_form_delete in Examples for Developers 7
Submit function for "Claim and delete" button.
Related topics
1 string reference to 'queue_example_add_remove_form_delete'
- queue_example_add_remove_form in queue_example/
queue_example.module - Form generator for managing the queue.
File
- queue_example/
queue_example.module, line 227 - Examples demonstrating the Drupal Queue API.
Code
function queue_example_add_remove_form_delete($form, &$form_state) {
$queue = DrupalQueue::get($form_state['values']['queue_name']);
// There is no harm in trying to recreate existing.
$queue
->createQueue();
$count = $queue
->numberOfItems();
$item = $queue
->claimItem(60);
if (!empty($item)) {
drupal_set_message(t('Claimed and deleted 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'],
)));
$queue
->deleteItem($item);
$count = $queue
->numberOfItems();
drupal_set_message(t('There are now @count items in the queue.', array(
'@count' => $count,
)));
}
else {
$count = $queue
->numberOfItems();
drupal_set_message(t('There were no items in the queue available to claim/delete. There are currently @count items in the queue.', array(
'@count' => $count,
)));
}
$form_state['rebuild'] = TRUE;
}