IcingaObjectImports: gracefully ignore empty members

This commit is contained in:
Thomas Gelf 2016-03-05 12:56:29 +01:00
parent 7498820700
commit f3e526f95f
1 changed files with 7 additions and 1 deletions

View File

@ -147,9 +147,16 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
public function add($import)
{
$class = $this->getImportClass();
// TODO: only one query when adding array
if (is_array($import)) {
foreach ($import as $i) {
// Gracefully ignore null members or empty strings
if (! $i instanceof $class && strlen($i) === 0) {
continue;
}
$this->add($i);
}
return $this;
@ -159,7 +166,6 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
return $this;
}
$class = $this->getImportClass();
$connection = $this->object->getConnection();
if ($import instanceof $class) {