IcingaHost, IcingaServiceForm: fix parse error...

...on PHP < 5.5
This commit is contained in:
Thomas Gelf 2016-09-08 11:32:41 +00:00
parent 6cc1a90b0a
commit 8dd7fcd13b
2 changed files with 7 additions and 5 deletions

View File

@ -279,19 +279,19 @@ class IcingaServiceForm extends DirectorObjectForm
protected function succeedForOverrides() protected function succeedForOverrides()
{ {
$vars = (object) array(); $vars = array();
foreach ($this->object->vars() as $key => $var) { foreach ($this->object->vars() as $key => $var) {
$vars->$key = $var->getValue(); $vars[$key] = $var->getValue();
} }
$host = $this->host; $host = $this->host;
$serviceName = $this->object->object_name; $serviceName = $this->object->object_name;
$this->host->overrideServiceVars($serviceName, $vars); $this->host->overrideServiceVars($serviceName, (object) $vars);
if ($host->hasBeenModified()) { if ($host->hasBeenModified()) {
$msg = sprintf( $msg = sprintf(
empty((array) $vars) empty($vars)
? $this->translate('All overrides have been removed from "%s"') ? $this->translate('All overrides have been removed from "%s"')
: $this->translate('The given properties have been stored for "%s"'), : $this->translate('The given properties have been stored for "%s"'),
$this->translate($host->object_name) $this->translate($host->object_name)

View File

@ -239,7 +239,9 @@ class IcingaHost extends IcingaObject
public function overrideServiceVars($service, $vars) public function overrideServiceVars($service, $vars)
{ {
if (empty((array) $vars)) { // For PHP < 5.5.0:
$array = (array) $vars;
if (empty($array)) {
return $this->unsetOverriddenServiceVars($service); return $this->unsetOverriddenServiceVars($service);
} }