summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Hodgdon2014-12-02 18:26:32 (GMT)
committer Jennifer Hodgdon2014-12-02 18:26:32 (GMT)
commit76e3d53c1f55564e3d01d6a3b5f3d2d5550ee858 (patch)
tree5d7b943f4efc8e8da06d219580bda05f6b51140e
parent1e3e775f57f9140fc2281fb1fe02ae39d3a97fc3 (diff)
Issue #2208649 by joachim, er.pushpinderrana: document queue worker callback7.x
-rw-r--r--modules/system/system.api.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 362e322..0af6156 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -606,8 +606,8 @@ function hook_cron() {
* @return
* An associative array where the key is the queue name and the value is
* again an associative array. Possible keys are:
- * - 'worker callback': The name of the function to call. It will be called
- * with one argument, the item created via DrupalQueue::createItem().
+ * - 'worker callback': A PHP callable to call that is an implementation of
+ * callback_queue_worker().
* - 'time': (optional) How much time Drupal should spend on calling this
* worker in seconds. Defaults to 15.
* - 'skip on cron': (optional) Set to TRUE to avoid being processed during
@@ -644,6 +644,28 @@ function hook_cron_queue_info_alter(&$queues) {
}
/**
+ * Work on a single queue item.
+ *
+ * Callback for hook_queue_info().
+ *
+ * @param $queue_item_data
+ * The data that was passed to DrupalQueue::createItem() when the item was
+ * queued.
+ *
+ * @throws \Exception
+ * The worker callback may throw an exception to indicate there was a problem.
+ * The cron process will log the exception, and leave the item in the queue to
+ * be processed again later.
+ *
+ * @see drupal_cron_run()
+ */
+function callback_queue_worker($queue_item_data) {
+ $node = node_load($queue_item_data);
+ $node->title = 'Updated title';
+ $node->save();
+}
+
+/**
* Allows modules to declare their own Form API element types and specify their
* default values.
*