You are here

function hook_hosting_task_update_status in Hosting 7.3

Same name and namespace in other branches
  1. 6.2 task/hosting_task.api.php \hook_hosting_task_update_status()
  2. 7.4 hosting.api.php \hook_hosting_task_update_status()

Reacts any time a task has it's status updated, including when being run in the queue, ending, or being cancelled.

Parameters

object $task: The task that has just completed. Note that $task->task_status has the old value, $status has the new value. The database will just have been updated before this hook is called.

int $status: The new status of that task. Can be HOSTING_TASK_SUCCESS, etc.

Related topics

3 invocations of hook_hosting_task_update_status()
hosting_task_insert in task/hosting_task.module
Implements hook_insert().
hosting_task_update in task/hosting_task.module
Implements hook_update().
hosting_task_update_status in task/hosting_task.module
Set a task's status according to its log.

File

./hosting.api.php, line 392
Hooks provided by the hosting module, and some other random ones.

Code

function hook_hosting_task_update_status($task, $status) {

  // A task's "RID" is a node ID for the object the task is run on. (Site, Platform, Server, etc)
  $node = node_load($task->rid);

  // On error, output a new message.
  if ($status == HOSTING_TASK_ERROR) {
    drush_log(dt("!title: !task task ended in an Error", array(
      '!task' => $task->task_type,
      '!title' => $node->title,
    )), 'error');
  }
  else {
    drush_log(" Task completed successfully: " . $task->task_type, 'ok');
    drush_log(dt("!title: !task task ended with !status", array(
      '!task' => $task->task_type,
      '!title' => $node->title,
      '!status' => _hosting_parse_error_code($status),
    )), 'ok');
  }
}