You are here

function queue_ui_cron in Queue UI 6

Same name and namespace in other branches
  1. 7.2 queue_ui.module \queue_ui_cron()
  2. 7 queue_ui.module \queue_ui_cron()

Implements hook_cron().

File

./queue_ui.module, line 101
queue_ui.module

Code

function queue_ui_cron() {

  // Retrieve queues set for cron processing.
  $defs = queue_ui_defined_queues();
  if (!empty($defs)) {
    foreach ($defs as $name => $definition) {
      $queue = DrupalQueue::get($name);

      // A cron callback must be defined and there must be items in the queue.
      if (isset($definition['cron']) && is_object($queue) && $queue
        ->numberOfItems()) {
        $active = variable_get('queue_ui_cron_' . $name, FALSE);
        if ($active) {

          // Pass $queue to cron callback for processing.
          $function = $definition['cron']['callback'];

          // Definitions can define arguments.
          $args = isset($definition['cron']['callback']) ? $definition['cron']['callback'] : NULL;
          $function($queue, $args);
        }
      }
    }
  }
}