Commit 6ef19c36 authored by Adrian Rossouw's avatar Adrian Rossouw

Remove more magic. d($this->context) is no longer needed. Use $this->context.

parent 02399ce3
...@@ -60,13 +60,13 @@ class provisionService_db extends provisionService { ...@@ -60,13 +60,13 @@ class provisionService_db extends provisionService {
* Find a viable database name, based on the site's uri. * Find a viable database name, based on the site's uri.
*/ */
function suggest_db_name() { function suggest_db_name() {
$uri = d($this->context)->uri; $uri = $this->context->uri;
$suggest_base = str_replace(array('.', '-'), '' , ereg_replace('^www\.', '', $uri)); $suggest_base = str_replace(array('.', '-'), '' , ereg_replace('^www\.', '', $uri));
$suggest[] = substr($suggest_base, 0, 16); $suggest[] = substr($suggest_base, 0, 16);
for ($i = 0; $i < 100; $i++) { 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) { foreach ($suggest as $option) {
...@@ -231,7 +231,7 @@ class provisionService_db extends provisionService { ...@@ -231,7 +231,7 @@ class provisionService_db extends provisionService {
* access to the site database. * access to the site database.
*/ */
function grant_host_list() { 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()));
} }
/** /**
......
...@@ -125,7 +125,7 @@ class provisionService_example_basic extends provisionService_example { ...@@ -125,7 +125,7 @@ class provisionService_example_basic extends provisionService_example {
*/ */
function verify() { function verify() {
parent::verify(); parent::verify();
if (d($this->context)->type == 'server') { if ($this->context->type == 'server') {
// Create the configuration file directory. // Create the configuration file directory.
provision_file()->create_dir($this->server->example_config_path, dt("Example configuration"), 0700); provision_file()->create_dir($this->server->example_config_path, dt("Example configuration"), 0700);
// Sync the directory to the remote server if needed. // Sync the directory to the remote server if needed.
......
...@@ -48,7 +48,7 @@ class provisionService_http_cluster extends provisionService_http { ...@@ -48,7 +48,7 @@ class provisionService_http_cluster extends provisionService_http {
function grant_server_list() { function grant_server_list() {
return array_merge( return array_merge(
array_map('d', $this->server->cluster_web_servers), array_map('d', $this->server->cluster_web_servers),
array(d($this->context)->platform->server) array($this->context->platform->server)
); );
} }
} }
...@@ -74,7 +74,7 @@ class provisionService_http_public extends provisionService_http { ...@@ -74,7 +74,7 @@ class provisionService_http_public extends provisionService_http {
function verify() { function verify() {
if (d()->type === 'server') { if ($this->context->type === 'server') {
if (!is_null($this->application_name)) { if (!is_null($this->application_name)) {
provision_file()->create_dir($this->server->http_confd_path, dt("Webserver custom configuration"), 0700); provision_file()->create_dir($this->server->http_confd_path, dt("Webserver custom configuration"), 0700);
$this->sync($this->server->http_confd_path); $this->sync($this->server->http_confd_path);
...@@ -91,7 +91,7 @@ class provisionService_http_public extends provisionService_http { ...@@ -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(); $this->parse_configs();
} }
...@@ -115,7 +115,7 @@ class provisionService_http_public extends provisionService_http { ...@@ -115,7 +115,7 @@ class provisionService_http_public extends provisionService_http {
function grant_server_list() { function grant_server_list() {
return array( return array(
$this->server, $this->server,
d($this->context)->platform->server, $this->context->platform->server,
); );
} }
......
...@@ -64,11 +64,14 @@ class provisionConfig { ...@@ -64,11 +64,14 @@ class provisionConfig {
if (is_null($this->template)) { if (is_null($this->template)) {
throw(exception); throw(exception);
} }
$this->data = $this->parse(); $this->data = $this->parse();
if (sizeof($data)) { if (sizeof($data)) {
$this->data = array_merge($this->data, $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);
} }
/** /**
......
...@@ -18,6 +18,10 @@ function & d($name = NULL, $_root_object = FALSE) { ...@@ -18,6 +18,10 @@ function & d($name = NULL, $_root_object = FALSE) {
static $instances = null; static $instances = null;
static $default_instance = '@self'; static $default_instance = '@self';
if (is_object($name)) {
return $name;
}
if ($name == 'all') { if ($name == 'all') {
return $instances; return $instances;
} }
......
...@@ -112,11 +112,11 @@ class provisionService extends provisionChainedState { ...@@ -112,11 +112,11 @@ class provisionService extends provisionChainedState {
} }
function __construct($server) { function __construct($server) {
$this->server = d($server); $this->server = is_object($server) ? $server : d($server);
} }
function setContext($name) { function setContext($context) {
$this->context = $name; $this->context = is_object($context) ? $context : d($context);
} }
function sync($path = NULL, $additional_options = array()) { function sync($path = NULL, $additional_options = array()) {
......
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