[icinga-checkins] icinga.org: icingaweb2-module-director/feature/nested-apply-rules-12033: IcingaRelatedObject: fix syntax, add comment...

git at icinga.org git at icinga.org
Fri Oct 21 10:08:05 CEST 2016


Module: icingaweb2-module-director
Branch: feature/nested-apply-rules-12033
Commit: 558ea82203e36ef7f27ee81912b2a8f8bbd518eb
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=558ea82203e36ef7f27ee81912b2a8f8bbd518eb

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri Oct 14 10:40:29 2016 +0000

IcingaRelatedObject: fix syntax, add comment...

...stating that this is unfinished

---

 library/Director/Objects/IcingaRelatedObject.php |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/library/Director/Objects/IcingaRelatedObject.php b/library/Director/Objects/IcingaRelatedObject.php
index f6d4f55..d35bcb0 100644
--- a/library/Director/Objects/IcingaRelatedObject.php
+++ b/library/Director/Objects/IcingaRelatedObject.php
@@ -7,7 +7,7 @@ use Icinga\Module\Director\Objects\IcingaObject;
 
 /**
  * Related Object
- * 
+ *
  * This class comes in handy when working with simple foreign key references. In
  * contrast to an ORM it helps to deal with lazy-loaded objects in a way allowing
  * us to render objects with references which to no longer (or not yet) exist
@@ -102,6 +102,8 @@ class IcingaRelatedObject
      */
     public function getObject()
     {
+        // TODO: This is unfinished
+
         if ($this->object === null) {
             $class = $this->getClassName();
 
@@ -109,7 +111,7 @@ class IcingaRelatedObject
                 if ($id = $this->getId()) {
                 }
             } else {
-                $this->object = $class::load($this->name, $this->
+                $this->object = $class::load($this->name, $this->owner->getConnection());
             }
         }
         return $this->object;
@@ -152,7 +154,7 @@ class IcingaRelatedObject
     /**
      * Set a related property
      *
-     * This might be a string or an object 
+     * This might be a string or an object
      * @param $related string|IcingaObject
      * @throws ProgrammingError
      *
@@ -163,7 +165,8 @@ class IcingaRelatedObject
         if (is_string($related)) {
             $this->name = $related;
         } elseif (is_object($related)) {
-            if ($related instanceof $this->getClassName()) {
+            $className = $this->getClassName();
+            if ($related instanceof $className) {
                 $this->object = $related;
                 $this->name = $object->object_name;
                 $this->id = $object->id;
@@ -201,7 +204,7 @@ class IcingaRelatedObject
     /**
      * Conservative constructor to avoid issued with PHP GC
      */
-    public function __construct()
+    public function __destruct()
     {
         unset($this->owner);
     }



More information about the icinga-checkins mailing list