Commit 44e64af2 authored by Jon Pugh's avatar Jon Pugh

- Move the platform property loading code into a method....

- Move the platform property loading code into a method. SaveCommand::loadPlatformProperties() now loads http service from platform as well.
- Also removing check for interactive returning out of askForServiceProperties because that code does the service adding. without it it won't work.
- Remove the dynamic loading of http service subscription from platform.
parent 1c1f3c38
......@@ -184,24 +184,7 @@ class SaveCommand extends Command
}
// Pass platform options into Site Options
if ($this->context_type == 'site') {
if ($input->getOption('platform') && $platform = $this->getProvision()->getContext($input->getOption('platform'))) {
foreach ($platform->getProperties() as $name => $value) {
if ($name != 'name' && $name != 'type' && $this->input->hasOption($name)) {
$this->getProvision()->getLogger()->notice("Setting option '{name}' from platform to '{value}'.", [
'name' => $name,
'value' => $value,
]);
// If the symfony console option is an empty string, it
if (empty($value)) {
$value = FALSE;
}
$this->input->setOption($name, $value);
}
}
}
}
$this->loadPlatformProperties();
$options = $this->askForContextProperties();
$options['name'] = $this->context_name;
......@@ -290,6 +273,40 @@ class SaveCommand extends Command
}
/**
* Takes --platform option, loads it, and parses properties from that into
* input options for the site.
*/
private function loadPlatformProperties() {
if ($this->context_type == 'site') {
if ($this->input->getOption('platform') && $platform = $this->getProvision()->getContext($this->input->getOption('platform'))) {
// Convert HTTP server to server_http option.
if ($platform->hasService('http')) {
$this->input->setOption('server_http', $platform->service('http')->provider->name);
}
// Convert all platform properties to $input options.
foreach ($platform->getProperties() as $name => $value) {
if ($name != 'name' && $name != 'type' && $this->input->hasOption($name)) {
$this->getProvision()->getLogger()->notice("Setting option '{name}' from platform to '{value}'.", [
'name' => $name,
'value' => $value,
]);
// Detect empty values, and pass FALSE instead.
// If we don't, $this->>askForContextProperties() will
// not see the option and will ask for it.
if (empty($value)) {
$value = FALSE;
}
$this->input->setOption($name, $value);
}
}
}
}
}
/**
* Override to add options
* @param string $question
......@@ -439,7 +456,7 @@ class SaveCommand extends Command
}
// If server_http is not specified, but it exists in the platform use that.
// Pass all options for this service to the services command.
$service_class = Service::getClassName($type);
$options_method = $this->input->getOption('context_type') . "_options";
......
......@@ -53,12 +53,12 @@ class SiteContext extends PlatformContext implements ConfigurationInterface
else {
$this->platform = NULL;
}
// Load http service from platform if site doesn't have them.
if (!isset($this->serviceSubscriptions['http']) && isset($this->platform) && $this->platform->hasService('http')) {
$this->serviceSubscriptions['http'] = $this->platform->getSubscription('http');
$this->serviceSubscriptions['http']->setContext($this);
}
// @TODO: Remove. Sites should require HTTP server natively. A platform just provides the default for new sites, and that is handled by SaveCommand::.
// // Load http service from platform if site doesn't have them.
// if (!isset($this->serviceSubscriptions['http']) && isset($this->platform) && $this->platform->hasService('http')) {
// $this->serviceSubscriptions['http'] = $this->platform->getSubscription('http');
// $this->serviceSubscriptions['http']->setContext($this);
// }
$uri = $this->getProperty('uri');
$this->properties['site_path'] = "sites/{$uri}";
......
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