[icinga-checkins] icinga.org: icingaweb2-module-director/fiddle/mfrosch: IcingaObject: smaller methods for import resolvers

git at icinga.org git at icinga.org
Fri May 20 13:14:59 CEST 2016


Module: icingaweb2-module-director
Branch: fiddle/mfrosch
Commit: 018713a13f58052d7bc43ae3ec0ce20a92f20ffc
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=018713a13f58052d7bc43ae3ec0ce20a92f20ffc

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri May 20 08:36:07 2016 +0200

IcingaObject: smaller methods for import resolvers

---

 library/Director/Objects/IcingaObject.php |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index 9358249..c4f2d5b 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -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;



More information about the icinga-checkins mailing list