function hook_hosting_TASK_OBJECT_context_options

7.x-3.x hosting.api.php hook_hosting_TASK_OBJECT_context_options(&$task)

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.


object $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




Related topics


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


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);