function progress_set_progress in Background Process 8
Set progress.
1 call to progress_set_progress()
- progress_set_intervalled_progress in progress/
progress.module - Set intervalled progress.
File
- progress/
progress.module, line 34 - Progress framework for keeping track of progresses. @todo Force MyISAM for table {progress} to avoid transaction/isolation level problems, and use INSERT DELAYED for performance.
Code
function progress_set_progress($name, $message, $progress) {
$current = microtime(TRUE);
$result = db_update('progress')
->fields([
'progress' => $progress,
'message' => $message,
'current_stamp' => $current,
])
->condition('name', $name)
->execute();
if (\Drupal::moduleHandler()
->moduleExists('nodejs')) {
$start_stamp = db_query("SELECT start_stamp FROM {progress} WHERE name = :name", [
':name' => $name,
])
->fetchField();
$object = (object) [
'name' => $name,
'progress' => $progress,
'message' => $message,
'current_stamp' => $current,
'start_stamp' => $start_stamp,
];
$message = (object) [
'channel' => 'progress',
'data' => (object) [
'action' => 'setProgress',
'progress' => $object,
'timestamp' => microtime(TRUE),
],
'callback' => 'nodejsProgress',
];
\Drupal::moduleHandler()
->alter('progress_message', $message);
nodejs_send_content_channel_message($message);
}
return $result;
}