IcingaObject: smaller methods for import resolvers

This commit is contained in:
Thomas Gelf 2016-05-20 08:36:07 +02:00
parent df2a5899f6
commit 018713a13f
1 changed files with 14 additions and 9 deletions

View File

@ -564,21 +564,26 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
if ($this->importedObjects === null) {
$this->importedObjects = array();
foreach ($this->imports()->listImportNames() as $import) {
if (is_array($this->getKeyName())) {
// Affects services only:
$this->importedObjects[$import] = self::load(
array('object_name' => $import),
$this->connection
);
} else {
$this->importedObjects[$import] = self::load($import, $this->connection);
}
$this->importedObjects[$import] = $this->loadImportedObject($import);
}
}
return $this->importedObjects;
}
protected function loadImportedObject($name)
{
if (is_array($this->getKeyName())) {
// Affects services only:
return self::load(
array('object_name' => $import),
$this->connection
);
} else {
return self::load($name, $this->connection);
}
}
public function clearImportedObjects()
{
$this->importedObjects = null;