]> projects.mako.cc - scuttle/blobdiff - services/servicefactory.php
updated readme with information on a series of bugs I know exist
[scuttle] / services / servicefactory.php
index 5f7635a91ebcc1500b8cdf28261300308284338c..7186b059ab89f7ad971da7d3b060358adffdb667 100644 (file)
@@ -1,11 +1,10 @@
 <?php
 class ServiceFactory {
-    function ServiceFactory(&$db, $serviceoverrules = array()) {
+    function ServiceFactory() {
     }
 
     function &getServiceInstance($name, $servicedir = NULL) {
         global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
-        static $instances = array();
         static $db;
         if (!isset($db)) {
             require_once dirname(__FILE__) .'/../includes/db/'. $dbtype .'.php';
@@ -15,6 +14,8 @@ class ServiceFactory {
                 message_die(CRITICAL_ERROR, "Could not connect to the database", $db);
             }
         }
+
+        static $instances = array();
         if (!isset($instances[$name])) {
             if (isset($serviceoverrules[$name])) {
                 $name = $serviceoverrules[$name];
@@ -25,7 +26,7 @@ class ServiceFactory {
                 }
                 require_once $servicedir . strtolower($name) .'.php';
             }
-            $instances[$name] = call_user_func(array($name, 'getInstance'), $db);
+            $instances[$name] = (new $name($db))->getInstance($db);
         }
         return $instances[$name];
     }

Benjamin Mako Hill || Want to submit a patch?