Commit 49c0d5ea authored by helmo's avatar helmo

Issue #2952999 by Jon Pugh, helmo: Merge remote-tracking branch...

Issue #2952999 by Jon Pugh, helmo: Merge remote-tracking branch 'origin/2952999-allow-alter-contexts' into 7.x-3.x
parents 18405d6e 35d478c0
......@@ -82,6 +82,22 @@ function hook_provision_services() {
return array('db' => NULL);
}
/**
* Alter a Context immediately after it is loaded and the 'init' methods are run.
*
* If replacing the context with a new object, be sure to implement the methods
* $context->method_invoke('init) and $context->type_invoke('init');
*
* @param $context \Provision_Context|\Provision_Context_server|\Provision_Context_site|\Provision_Context_platform
*
* @see provision.context.inc#72
*/
function hook_provision_context_alter(&$context) {
$context = new Provision_Context_Server_alternate($context->name);
$context->method_invoke('init');
$context->type_invoke('init');
}
/**
* Append PHP code to Drupal's settings.php file.
*
......
......@@ -69,6 +69,10 @@ function & d($name = NULL, $_root_object = FALSE, $allow_creation = TRUE) {
if (!is_null($instances[$name])) {
$instances[$name]->method_invoke('init');
$instances[$name]->type_invoke('init');
// Allow drush modules to alter the class being loaded.
drush_command_invoke_all_ref('provision_context_alter', $instances[$name]);
}
return $instances[$name];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment