X-Git-Url: https://projects.mako.cc/source/scuttle/blobdiff_plain/c20b44263a89d8bf1a78bfa632daaae3cb4f1da2..HEAD:/services/servicefactory.php diff --git a/services/servicefactory.php b/services/servicefactory.php index ba2d6d7..7186b05 100644 --- a/services/servicefactory.php +++ b/services/servicefactory.php @@ -1,20 +1,21 @@ sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist); if(!$db->db_connect_id) { 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]; @@ -23,11 +24,10 @@ class ServiceFactory { if (!isset($servicedir)) { $servicedir = dirname(__FILE__) .'/'; } - require_once($servicedir . strtolower($name) . '.php'); + 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]; } } -?> \ No newline at end of file