server/src/app/Libraries/Utils.php
changeset 261 02e2396bcbbc
parent 141 c0e8626a271c
child 329 0a2c2ad49d75
--- a/server/src/app/Libraries/Utils.php	Sat Aug 06 21:27:53 2016 +0700
+++ b/server/src/app/Libraries/Utils.php	Sat Aug 06 21:29:33 2016 +0700
@@ -3,6 +3,8 @@
 
 use EasyRdf\Literal;
 use EasyRdf\Resource;
+use EasyRdf\Graph;
+
 
 /**
  * Utilities functions
@@ -117,5 +119,19 @@
         }
     }
 
+    /**
+     * @param EasyRdf\Graph $graph1
+     * @param EasyRdf\Graph $graph2
+     *
+     * @return EasyRdf\Graph
+     */
+    public static function mergeGraphs(Graph $graph1, Graph $graph2)
+    {
+        $data1 = $graph1->toRdfPhp();
+        $data2 = $graph2->toRdfPhp();
+        $merged = array_merge_recursive($data1, $data2);
+        unset($data1, $data2);
+        return new Graph($graph1->getUri(), $merged, 'php');
+    }
 
 }