diff --git a/db/db.drush.inc b/db/db.drush.inc index d4e37903742154ca0bd5b197d325e283d62a5e43..d8d6b275e025c16c6573662390b87aa43277d022 100644 --- a/db/db.drush.inc +++ b/db/db.drush.inc @@ -60,13 +60,13 @@ class provisionService_db extends provisionService { * Find a viable database name, based on the site's uri. */ function suggest_db_name() { - $uri = d($this->context)->uri; + $uri = $this->context->uri; $suggest_base = str_replace(array('.', '-'), '' , ereg_replace('^www\.', '', $uri)); $suggest[] = substr($suggest_base, 0, 16); for ($i = 0; $i < 100; $i++) { - $suggest[] = sprintf("%s_%d", substr($suggest_base, 0, 16 - strlen( (string) $i) ), $i); + $suggest[] = sprintf("%s_%d", substr($suggest_base, 0, 15 - strlen( (string) $i) ), $i); } foreach ($suggest as $option) { @@ -231,7 +231,7 @@ class provisionService_db extends provisionService { * access to the site database. */ function grant_host_list() { - return array_unique(array_map(array($this, 'grant_host'), d($this->context)->service('http')->grant_server_list())); + return array_unique(array_map(array($this, 'grant_host'), $this->context->service('http')->grant_server_list())); } /** diff --git a/example/basic/basic_service.inc b/example/basic/basic_service.inc index fcfc918a9d65360be731f8324ff0e1d61cf039d0..2c38b22e916f51349ea72531aef58d1fad924c9b 100644 --- a/example/basic/basic_service.inc +++ b/example/basic/basic_service.inc @@ -125,7 +125,7 @@ class provisionService_example_basic extends provisionService_example { */ function verify() { parent::verify(); - if (d($this->context)->type == 'server') { + if ($this->context->type == 'server') { // Create the configuration file directory. provision_file()->create_dir($this->server->example_config_path, dt("Example configuration"), 0700); // Sync the directory to the remote server if needed. diff --git a/http/cluster/cluster_service.inc b/http/cluster/cluster_service.inc index c88e196da60ae63eff950d84eb5980c9943059b3..8f24dd2a58c3cc3f0220b4dc0bf7578aa5fe4c46 100644 --- a/http/cluster/cluster_service.inc +++ b/http/cluster/cluster_service.inc @@ -48,7 +48,7 @@ class provisionService_http_cluster extends provisionService_http { function grant_server_list() { return array_merge( array_map('d', $this->server->cluster_web_servers), - array(d($this->context)->platform->server) + array($this->context->platform->server) ); } } diff --git a/http/http.drush.inc b/http/http.drush.inc index 5f8858b9a739de3ceadbb2cf8ca0d76b62c3f4c2..cf15e5953b5d8fb239f72d295620dc6b5f2ff3cd 100644 --- a/http/http.drush.inc +++ b/http/http.drush.inc @@ -74,7 +74,7 @@ class provisionService_http_public extends provisionService_http { function verify() { - if (d()->type === 'server') { + if ($this->context->type === 'server') { if (!is_null($this->application_name)) { provision_file()->create_dir($this->server->http_confd_path, dt("Webserver custom configuration"), 0700); $this->sync($this->server->http_confd_path); @@ -91,7 +91,7 @@ class provisionService_http_public extends provisionService_http { } } - $this->create_config(d()->type); + $this->create_config($this->context->type); $this->parse_configs(); } @@ -115,7 +115,7 @@ class provisionService_http_public extends provisionService_http { function grant_server_list() { return array( $this->server, - d($this->context)->platform->server, + $this->context->platform->server, ); } diff --git a/provision.config.inc b/provision.config.inc index f3b19d24714b947f62e577a4e63dba1509821d61..9126f61dd3a5271fdc526db7739878609adbc1c7 100644 --- a/provision.config.inc +++ b/provision.config.inc @@ -64,11 +64,14 @@ class provisionConfig { if (is_null($this->template)) { throw(exception); } + $this->data = $this->parse(); if (sizeof($data)) { $this->data = array_merge($this->data, $data); } - $this->owner = d($owner); + + // Accept both a reference and an alias name for the owner. + $this->owner = is_object($owner) ? $owner : d($owner); } /** diff --git a/provision.environment.inc b/provision.environment.inc index 1afc2a95702b95d0615c9a855b79bdf2c403b1bb..8df781d2d854668b84e7a6cc935f1b6fd8bff104 100644 --- a/provision.environment.inc +++ b/provision.environment.inc @@ -18,6 +18,10 @@ function & d($name = NULL, $_root_object = FALSE) { static $instances = null; static $default_instance = '@self'; + if (is_object($name)) { + return $name; + } + if ($name == 'all') { return $instances; } diff --git a/provision.service.inc b/provision.service.inc index dd5c39a7818a215fc1d1d29246d04fb8532bf5dc..a111bc4e0f1c83c20b485472e100c151bf94639f 100644 --- a/provision.service.inc +++ b/provision.service.inc @@ -112,11 +112,11 @@ class provisionService extends provisionChainedState { } function __construct($server) { - $this->server = d($server); + $this->server = is_object($server) ? $server : d($server); } - function setContext($name) { - $this->context = $name; + function setContext($context) { + $this->context = is_object($context) ? $context : d($context); } function sync($path = NULL, $additional_options = array()) {