IcingaObjectImports: simplify code

This commit is contained in:
Thomas Gelf 2015-07-31 14:33:09 +02:00
parent bdb7d22e99
commit 48a8e1ab63
1 changed files with 2 additions and 12 deletions

View File

@ -158,19 +158,9 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
if ($import instanceof $class) { if ($import instanceof $class) {
$this->imports[$import->object_name] = $import; $this->imports[$import->object_name] = $import;
} elseif (is_string($import)) { } elseif (is_string($import)) {
$query = $this->object->getDb()->select()->from( $import = $class::load($import, $connection);
$this->object->getTableName() $this->imports[$import->object_name] = $import;
)->where('object_name = ?', $import);
$imports = $class::loadAll($connection, $query, 'object_name');
} }
if (! array_key_exists($import, $imports)) {
throw new ProgrammingError(
'The import "%s" doesn\'t exists.',
$import
);
}
$this->imports[$import] = $imports[$import];
$this->modified = true; $this->modified = true;
$this->refreshIndex(); $this->refreshIndex();