Commit 115d394c authored by drumm's avatar drumm Committed by Neil Drumm

Centralize service initialization.

parent a9b0ef46
......@@ -8,34 +8,8 @@
* It uses the provision API to tie into the right places in the site creation work flow.
*/
include_once(dirname(__FILE__) . '/../provision.service.inc');
function db_drush_init() {
// todo same as http, consolidate
$command = drush_get_command();
$command = explode(" ", $command['command']);
if (preg_match("/^provision-/", $command[0])) {
_provision_context_init();
if (PROVISION_CONTEXT_SERVER) {
if (!is_null(drush_get_option('init_db'))) {
// Bootstrap for alias creation.
include_once(drush_get_option('init_db') . '/'. drush_get_option('init_db') .'_service.inc');
$class = 'provisionService_db_' . drush_get_option('init_db');
provision_service('db', new $class());
}
}
elseif (PROVISION_CONTEXT_SITE) {
// todo should be constructed based on drush aliases
include_once('mysql/mysql_service.inc');
provision_service('db', new provisionService_db_mysql());
}
}
// this is where we generate the db service object.
}
function db_drush_exit() {
// determine how to close it too.
provision_service('db')->close();
......
......@@ -2,29 +2,6 @@
include_once(dirname(__FILE__) . '/../provision.service.inc');
function http_drush_init() {
// todo same as db, consolidate
$command = drush_get_command();
$command = explode(" ", $command['command']);
if (preg_match("/^provision-/", $command[0])) {
_provision_context_init();
if (PROVISION_CONTEXT_SERVER) {
if (!is_null(drush_get_option('init_http'))) {
// Bootstrap for alias creation.
include_once(drush_get_option('init_http') . '/'. drush_get_option('init_http') .'_service.inc');
$class = 'provisionService_http_' . drush_get_option('init_http');
provision_service('http', new $class());
}
}
else {
// todo should be constructed based on drush aliases
include_once('apache/apache_service.inc');
provision_service('http', new provisionService_http_apache());
}
}
}
class provisionService_http extends provisionService {
/**
* Set defaults
......
......@@ -54,7 +54,6 @@ function provision_drupal_drush_init() {
$command = drush_get_command();
$command = explode(" ", $command['command']);
if (preg_match("/^provision-/", $command[0])) {
_provision_context_init();
}
......@@ -86,6 +85,15 @@ function _provision_context_init() {
drush_log(dt('Using context @context', array('@context' => $context)));
// Initialize services.
foreach (array('db', 'http') as $service) {
if (!is_null(drush_get_option('init_' . $service))) {
include_once(drush_get_option('init_' . $service) . '/'. drush_get_option('init_' . $service) .'_service.inc');
$class = 'provisionService_' . $service . '_' . drush_get_option('init_' . $service);
provision_service($service, new $class());
}
}
$is_run = TRUE;
}
......
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