public function UltimateCronJob::sendMessage in Ultimate Cron 7.2
Send a nodejs message.
Parameters
string $action: The action performed.
array $data: Data blob for the given action.
3 calls to UltimateCronJob::sendMessage()
- UltimateCronJob::lock in ./
ultimate_cron.job.inc - Lock job.
- UltimateCronJob::setProgress in ./
ultimate_cron.job.inc - Set job progress.
- UltimateCronJob::unlock in ./
ultimate_cron.job.inc - Unlock job.
File
- ./
ultimate_cron.job.inc, line 698 - Job class for Ultimate Cron.
Class
- UltimateCronJob
- Class for handling cron jobs.
Code
public function sendMessage($action, $data = array()) {
if (module_exists('nodejs')) {
$settings = _ultimate_cron_plugin_require('settings', 'general')
->getDefaultSettings();
if (empty($settings['nodejs'])) {
return;
}
$elements = array();
$build = clone $this;
$cell_idxs = array();
switch ($action) {
case 'lock':
$logger = $build
->getPlugin('logger');
if (empty($data['log_entry'])) {
$build->lock_id = $data['lock_id'];
$build->log_entry = $logger
->factoryLogEntry($build->name);
$build->log_entry
->setData(array(
'lid' => $data['lock_id'],
'start_time' => microtime(TRUE),
));
}
else {
$build->log_entry = $data['log_entry'];
}
$cell_idxs = array(
'tr#' . $build->name . ' .ctools-export-ui-start-time' => 3,
'tr#' . $build->name . ' .ctools-export-ui-duration' => 4,
'tr#' . $build->name . ' .ctools-export-ui-status' => 5,
'tr#' . $build->name . ' .ctools-export-ui-operations' => 7,
);
break;
case 'unlock':
$build->log_entry = $build
->loadLogEntry($data['lock_id']);
$build->lock_id = FALSE;
$cell_idxs = array(
'tr#' . $build->name . ' .ctools-export-ui-start-time' => 3,
'tr#' . $build->name . ' .ctools-export-ui-duration' => 4,
'tr#' . $build->name . ' .ctools-export-ui-status' => 5,
'tr#' . $build->name . ' .ctools-export-ui-operations' => 7,
);
break;
case 'setProgress':
$build->lock_id = $build
->isLocked();
$build->log_entry = $build
->loadLogEntry($build->lock_id);
$cell_idxs = array(
'tr#' . $build->name . ' .ctools-export-ui-start-time' => 3,
'tr#' . $build->name . ' .ctools-export-ui-duration' => 4,
'tr#' . $build->name . ' .ctools-export-ui-status' => 5,
);
break;
}
$cells = $build
->rebuild_ctools_export_ui_table_row();
foreach ($cell_idxs as $selector => $cell_idx) {
$elements[$selector] = $cells[$cell_idx];
}
$message = (object) array(
'channel' => 'ultimate_cron',
'data' => (object) array(
'action' => $action,
'job' => $build,
'timestamp' => microtime(TRUE),
'elements' => $elements,
),
'callback' => 'nodejsUltimateCron',
);
nodejs_send_content_channel_message($message);
}
}