function hook_post_hosting_TASK_TYPE_task

7.x-3.x hosting.api.php hook_post_hosting_TASK_TYPE_task($task, $data)

Perform actions when a task has completed succesfully.

Replace TASK_TYPE with the type of task that if completed you will be notified of. This is a good place to hook in and record changes in the frontend as a result of the task executing in the backend. If you just want to hook into the backend then you probably want to consider using the 'standard' Drush hooks there, i.e. host_post_provision_verify(), hook_post_provision_install() etc.

Parameters

object $task: The hosting task that has completed.

array $data: An associative array of the drush output of the completed backend task from drush_backend_output(). The array should contain at least the following:

  • "output": The raw output from the drush command executed.
  • "error_status": The error status of the command run on the backend, should be DRUSH_SUCCESS normally.
  • "log": The drush log messages.
  • "error_log": The list of errors that occurred when running the command.
  • "context": The drush options for the backend command, this may contain options that were set when the command ran, or options that were set by the command itself.

See also

drush_hosting_post_hosting_task()

drush_backend_output()

Related topics

File

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

Code

function hook_post_hosting_TASK_TYPE_task($task, $data) {
  // From hosting_site_post_hosting_backup_task().
  if ($data['context']['backup_file'] && $task->ref->type == 'site') {
    $platform = node_load($task->ref->platform);

    $desc = $task->task_args['description'];
    $desc = ($desc) ? $desc : t('Generated on request');
    hosting_site_add_backup($task->ref->nid, $platform->web_server, $data['context']['backup_file'], $desc, $data['context']['backup_file_size']);
  }
}