You are here

function elysia_cron_cronapi in Elysia Cron 7.2

Same name and namespace in other branches
  1. 6.2 elysia_cron.module \elysia_cron_cronapi()

Implements hook_cronapi().

File

./elysia_cron.module, line 1872

Code

function elysia_cron_cronapi($op, $job = FALSE) {
  $items = array();
  $queues = module_invoke_all('cron_queue_info');
  drupal_alter('cron_queue_info', $queues);
  foreach ($queues as $queue_name => $info) {
    if (!empty($info['skip on cron'])) {

      // Do not run if queue wants to skip.
      continue;
    }

    // Make sure every queue exists. There is no harm in trying to recreate an
    // existing queue.
    $queue = DrupalQueue::get($queue_name);
    $queue
      ->createQueue();

    // Some queue backends may have performance issues with counting items.
    if (variable_get('elysia_cron_queue_show_count', TRUE)) {
      $queue_description = $queue_name . ' queue processing (Items count: <strong>' . $queue
        ->numberOfItems() . '</strong>, worker max duration: <strong>' . (isset($info['time']) ? $info['time'] . 's' : t('unspecified') . ' (15s)') . '</strong>)';
    }
    else {
      $queue_description = $queue_name . ' queue processing (Worker max duration: <strong>' . (isset($info['time']) ? $info['time'] . 's' : t('unspecified') . ' (15s)') . '</strong>)';
    }
    $items['queue_' . $queue_name] = array(
      'description' => $queue_description,
      'rule' => variable_get('elysia_cron_queue_default_rule', FALSE),
      'weight' => variable_get('elysia_cron_queue_default_weight', 100),
      'callback' => 'elysia_cron_queue_exec',
      'arguments' => array(
        $queue_name,
        $info,
      ),
    );
  }
  return $items;
}