IcingaObjectImports: simplify code
This commit is contained in:
parent
bdb7d22e99
commit
48a8e1ab63
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue