You are here

function hook_post_hosting_TASK_TYPE_task in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 hosting.api.php \hook_post_hosting_TASK_TYPE_task()
  2. 7.3 hosting.api.php \hook_post_hosting_TASK_TYPE_task()

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

$task: The hosting task that has completed.

$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

17 functions implement hook_post_hosting_TASK_TYPE_task()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

hosting_clone_post_hosting_clone_task in clone/hosting_clone.drush.inc
hosting_migrate_post_hosting_migrate_task in migrate/hosting_migrate.drush.inc
hosting_platform_post_hosting_delete_task in platform/hosting_platform.drush.inc
Implementation of hook_hosting_post_DELETE().
hosting_platform_post_hosting_lock_task in platform/hosting_platform.drush.inc
hosting_platform_post_hosting_unlock_task in platform/hosting_platform.drush.inc

... See full list

File

./hosting.api.php, line 292
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']);
  }
}