Commit f9b9a55a authored by Jon Pugh's avatar Jon Pugh

Prepare Service classes in the ServerContext object.

parent f4861679
......@@ -40,7 +40,24 @@ class ServerContext extends Context implements ConfigurationInterface
{
parent::__construct($name, $console_config, $options);
if (isset($this->config['services'])) {
$this->services = $this->config['services'];
$this->prepareServices();
}
else {
$this->services = [];
}
print_r($this->services);
}
/**
* Load Service classes from config into Context..
*/
protected function prepareServices() {
foreach ($this->config['services'] as $service_name => $service) {
$service_name = ucfirst($service_name);
$service_type = ucfirst($service['type']);
$service_class = "\\Aegir\\Provision\\Service\\{$service_name}\\{$service_name}{$service_type}Service";
$this->services[strtolower($service_name)] = new $service_class($service, $this);
}
}
......@@ -202,11 +219,11 @@ class ServerContext extends Context implements ConfigurationInterface
if (!empty($this->getServices())) {
$rows = [];
foreach ($this->getServices() as $name => $service) {
$rows[] = [$name, $service['type']];
$rows[] = [$name, $service->type];
// Show all properties.
if (!empty($service['properties'] )) {
foreach ($service['properties'] as $name => $value) {
if (!empty($service->properties )) {
foreach ($service->properties as $name => $value) {
$rows[] = [' ' . $name, $value];
}
}
......
......@@ -11,7 +11,19 @@ namespace Aegir\Provision;
//require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc';
class Service {
public $type;
public $properties;
function __construct($service_config, $context) {
$this->context = $context;
$this->type = $service_config['type'];
$this->properties = $service_config['properties'];
}
/**
* LEGACY
*/
/**
* The server this service is associated to
*/
......@@ -316,10 +328,6 @@ class Service {
return FALSE;
}
function __construct($server) {
$this->server = is_object($server) ? $server : d($server);
}
/**
* Set the currently active context of the service.
*
......
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