You are here

function hook_hosting_TASK_OBJECT_context_options in Hosting 6.2

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

Add or change context options before a hosting task runs.

This hook is invoked just before any task that has the 'provision_save' flag equal to TRUE. These include the 'install', 'verify' and 'import' tasks.

The TASK_OBJECT will be either: 'server', 'platform' or 'site'.

This gives other modules the chance to send data to the backend to be persisted by services there. The entire task is sent so that you have access to it, but you should avoid changing things outside of the $task->content_options collection.

If you are sending extra context options to the backend based on properties in the object's node, then you should also implement the hook_drush_context_import() hook to re-create those properties on the node when a context is imported.

Parameters

$task: The hosting task that is about to be executed, the task is passed by reference. The context_options property of this object is about to be saved to the backend, so you can make any changes before that happens. Note that these changes won't persist in the backend unless you have a service that will store them.

The node representing the object of the task, e.g. the site that is being verified is available in the $task->ref property.

See also

drush_hosting_task()

hook_drush_context_import()

hook_hosting_tasks()

Related topics

6 functions implement hook_hosting_TASK_OBJECT_context_options()

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

hosting_hosting_platform_context_options in platform/hosting_platform.drush.inc
Implementation of hook_hosting_TASK_OBJECT_context_options().
hosting_hosting_server_context_options in server/hosting_server.drush.inc
Pass options for the server verification to the backend.
hosting_hosting_site_context_options in site/hosting_site.drush.inc
hosting_nginx_ssl_hosting_site_context_options in web_server/nginx/ssl/hosting_nginx_ssl.drush.inc
hosting_site_data_hosting_site_context_options in example/site_data/hosting_site_data.drush.inc
Implementation of hook_hosting_site_context_options().

... See full list

File

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

Code

function hook_hosting_TASK_OBJECT_context_options(&$task) {

  // From hosting_hosting_platform_context_options().
  $task->context_options['server'] = '@server_master';
  $task->context_options['web_server'] = hosting_context_name($task->ref->web_server);
}