You are here

function ultimate_cron_service_process_status in Ultimate Cron 7

Same name and namespace in other branches
  1. 8 ultimate_cron.admin.inc \ultimate_cron_service_process_status()

Send a message for all running processes.

1 string reference to 'ultimate_cron_service_process_status'
ultimate_cron_menu in ./ultimate_cron.module
Implements hook_menu().

File

./ultimate_cron.admin.inc, line 651

Code

function ultimate_cron_service_process_status() {
  $handle_prefix = variable_get('ultimate_cron_handle_prefix', ULTIMATE_CRON_HANDLE_PREFIX);
  $processes = array();
  $query = db_select('background_process', 'b')
    ->fields('b')
    ->condition('handle', $handle_prefix . '%', 'LIKE');
  foreach ($query
    ->execute()
    ->fetchAllAssoc('handle', PDO::FETCH_OBJ) as $process) {
    $process = BackgroundProcess::load($process);
    $name = preg_replace('/^' . $handle_prefix . '/', '', $process->handle);
    $processes[$name] = $process;
    $process
      ->sendMessage('ultimateCronStatus');
  }
  return drupal_json_output(array(
    'processes' => $processes,
  ));
}