Commit aab9ef08 authored by Jon Pugh's avatar Jon Pugh

Add "hasService()"" function for checking if a service exists without throwing an exception.

parent 8e109593
......@@ -212,6 +212,18 @@ class ServicesCommand extends Command
]));
}
if ($this->context->hasService($service)) {
$icon = Provision::ICON_EDIT;
$this->getProvision()->io()->block(
" {$icon} Editing service {} provded by {$this->context->name} ",
NULL,
'bg=black;fg=blue',
NULL,
TRUE
);
}
// Then ask for all options.
$properties = $this->askForServiceProperties($service, $service_type);
......@@ -276,7 +288,7 @@ class ServicesCommand extends Command
$property = Provision::newProperty($property);
}
if ($this->context->getService($service)->getProperty($name)) {
if ($this->context->hasService($service) && $this->context->getService($service)->getProperty($name)) {
$property->default = $this->context->getService($service)->getProperty($name);
}
......
......@@ -64,6 +64,21 @@ class ContextProvider extends Context
throw new \Exception("Service '$type' does not exist in the context '{$this->name}'.");
}
}
/**
* Whether or not this Server has a service.
*
* @param $type
* @return bool
*/
public function hasService($type) {
if (isset($this->services[$type])) {
return TRUE;
}
else {
return FALSE;
}
}
/**
* Return all services for this context.
......
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