You are here

function message_ui_arguments_worker in Message UI 7

Update the message arguments via a queue worker.

1 call to message_ui_arguments_worker()
MessageUiMassiveHardCodedArguments::testRemoveAddingArguments in ./message_ui.test
1 string reference to 'message_ui_arguments_worker'
message_ui_cron_queue_info in ./message_ui.module
Implements hook_cron_queue_info().

File

./message_ui.module, line 560
Main file for the message UI module.

Code

function message_ui_arguments_worker($data) {

  // Load all of the messages.
  $query = new entityFieldQuery();
  $result = $query
    ->entityCondition('entity_type', 'message')
    ->propertyCondition('type', $data['type'])
    ->propertyOrderBy('mid', 'DESC')
    ->propertyCondition('mid', $data['last_mid'], '>=')
    ->range(0, $data['item_to_process'])
    ->execute();
  if (empty($result['message'])) {
    return;
  }

  // Update the messages.
  $messages = message_load_multiple(array_keys($result['message']));
  foreach ($messages as $message) {
    _message_ui_arguments_update($message, $data['new_arguments']);
    $data['last_mid'] = $message->mid;
  }

  // Create the next queue worker.
  $queue = DrupalQueue::get('message_ui_arguments');
  return $queue
    ->createItem($data);
}