[icinga-checkins] icinga.org: icingaweb2-module-director/feature-ddo-playground: lib: Introduce DdoObject::merge() and hex2bin

git at icinga.org git at icinga.org
Tue Jul 19 10:31:53 CEST 2016


Module: icingaweb2-module-director
Branch: feature-ddo-playground
Commit: 678b4eeab195cd17b5186ab5ce3a40c84bf03b3a
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=678b4eeab195cd17b5186ab5ce3a40c84bf03b3a

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Tue Jun 21 17:07:32 2016 +0200

lib: Introduce DdoObject::merge() and hex2bin

---

 library/Director/Ddo/DdoObject.php |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/library/Director/Ddo/DdoObject.php b/library/Director/Ddo/DdoObject.php
index 38197fa..c19f802 100644
--- a/library/Director/Ddo/DdoObject.php
+++ b/library/Director/Ddo/DdoObject.php
@@ -2,6 +2,12 @@
 
 namespace Icinga\Module\Director\Ddo;
 
+if (version_compare(PHP_VERSION, '5.4.0') <= 0) {
+    function hex2bin($hex) {
+        return pack('H*', $hex);
+    }
+}
+
 use Icinga\Module\Director\Data\Db\DbObject;
 use Icinga\Exception\ProgrammingError;
 
@@ -54,4 +60,14 @@ abstract class DdoObject extends DbObject
             );
         }
     }
+
+    public function merge(DdoObject $other)
+    {
+        $this->hasBeenModified = false;
+        $this->loadedFromDb = true;
+
+        $properties = array_merge($other->getProperties(), $this->getProperties());
+
+        $this->setProperties($properties);
+    }
 }



More information about the icinga-checkins mailing list