[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaObject: move duplicate logic to common func

git at icinga.org git at icinga.org
Mon Oct 10 12:00:29 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: e96db8b296fc4f5747d0bda76b17a907e9b17970
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=e96db8b296fc4f5747d0bda76b17a907e9b17970

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sun Oct  9 13:15:05 2016 +0000

IcingaObject: move duplicate logic to common func

---

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

diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index 1063d0c..289bcf0 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1279,15 +1279,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
             return;
         }
 
-        $type = $this->getShortTableName();
-
-        if ($this->isTemplate()) {
-            $filename = strtolower($type) . '_templates';
-        } elseif ($this->isApplyRule()) {
-            $filename = strtolower($type) . '_apply';
-        } else {
-            $filename = strtolower($type) . 's';
-        }
+        $filename = $this->getRenderingFilename();
 
         if ($config->isLegacy()) {
 
@@ -1333,6 +1325,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
             return;
         }
 
+        $config->configFile(
+            'zones.d/' . $this->getRenderingZone($config) . '/' . $this->getRenderingFilename()
+        )->addObject($this);
+    }
+
+    public function getRenderingFilename()
+    {
         $type = $this->getShortTableName();
 
         if ($this->isTemplate()) {
@@ -1343,9 +1342,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
             $filename = strtolower($type) . 's';
         }
 
-        $config->configFile(
-            'zones.d/' . $this->getRenderingZone($config) . '/' . $filename
-        )->addObject($this);
+        return $filename;
     }
 
     public function getRenderingZone(IcingaConfig $config = null)



More information about the icinga-checkins mailing list