1 queue_example.module queue_example_add_remove_form_delete($form, &$form_state)

Submit function for "Claim and delete" button.

Related topics


modules/examples/queue_example/queue_example.module, line 225
Hook implementations for the Queue Example module.


function queue_example_add_remove_form_delete($form, &$form_state) {
  $queue = BackdropQueue::get($form_state['values']['queue_name']);
  // There is no harm in trying to recreate existing.
  $count = $queue->numberOfItems();
  $item = $queue->claimItem(60);
  if (!empty($item)) {
    t('Claimed and deleted item id=@item_id string=@string for @seconds seconds. There are @count items in the queue.', 
      '@count' => $count,
      '@item_id' => $item->item_id,
      '@string' => $item->data,
      '@seconds' => $form_state['values']['claim_time'],
    $count = $queue->numberOfItems();
    backdrop_set_message(t('There are now @count items in the queue.', array('@count' => $count)));
  else {
    $count = $queue->numberOfItems();
    backdrop_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;