Commit d7a6b5d4 authored by Steven Jones's avatar Steven Jones

Get the context factory working

parent 568047de
......@@ -33,24 +33,25 @@ function & d($name = NULL, $_root_object = FALSE, $allow_creation = TRUE) {
}
if (is_null($name)) {
return $instances[$default_instance];
$name = $default_instance;
}
else {
if ($_root_object) {
$default_instance = $name;
}
if ($_root_object) {
$default_instance = $name;
}
$name = provision_normalise_context_name($name);
if (isset($instances[$name])) {
return $instances[$name];
}
else {
$instances[$name] = provision_context_factory($name, $allow_creation);
if (!is_null($instances[$name])) {
$instances[$name]->method_invoke('init');
$instances[$name]->type_invoke('init');
}
return $instances[$name];
if (isset($instances[$name])) {
return $instances[$name];
}
else {
$instances[$name] = provision_context_factory($name, $allow_creation);
if (!is_null($instances[$name])) {
$instances[$name]->method_invoke('init');
$instances[$name]->type_invoke('init');
}
return $instances[$name];
}
}
......@@ -64,6 +65,8 @@ function & d($name = NULL, $_root_object = FALSE, $allow_creation = TRUE) {
*/
function provision_sitealias_get_record($name) {
static $cache = array();
$name = provision_normalise_context_name($name);
if (!isset($cache[$name])) {
$cache[$name] = drush_sitealias_get_record($name);
......
......@@ -87,6 +87,9 @@ function provision_drush_command() {
'examples' => array(
'drush @site provision-install' => 'Install the site as defined by the site Drush alias generated with provision-save.',
),
'options' => array(
'client_email' => dt('The email address of the client to use.'),
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
......
......@@ -741,6 +741,19 @@ function provision_version_parts() {
return explode('.', $version);
}
/**
* Normalise a context name, ensuring that it starts with one '@'.
*
* @param $name
* The context name to normalise.
*
* @return
* The normalised context name.
*/
function provision_normalise_context_name($name) {
return '@' . ltrim($name, '@');
}
// Base class for provision exceptions.
class provisionException extends Exception {
......
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