diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2007-12-12 16:29:16 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2007-12-12 16:29:16 +0000 |
commit | d582054c77b22daeb08d2bff17794b9a69a20dd4 (patch) | |
tree | d6e7cef8639da6f573cd0b21a5316abf5af24fac /services/servicefactory.php | |
download | semanticscuttle-d582054c77b22daeb08d2bff17794b9a69a20dd4.tar.gz semanticscuttle-d582054c77b22daeb08d2bff17794b9a69a20dd4.tar.bz2 |
import of scuttle 0.7.2
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@1 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'services/servicefactory.php')
-rw-r--r-- | services/servicefactory.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/services/servicefactory.php b/services/servicefactory.php new file mode 100644 index 0000000..ba2d6d7 --- /dev/null +++ b/services/servicefactory.php @@ -0,0 +1,33 @@ +<?php +class ServiceFactory { + function ServiceFactory(&$db, $serviceoverrules = array()) { + } + + 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'); + $db = new sql_db(); + $db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist); + if(!$db->db_connect_id) { + message_die(CRITICAL_ERROR, "Could not connect to the database", $db); + } + } + if (!isset($instances[$name])) { + if (isset($serviceoverrules[$name])) { + $name = $serviceoverrules[$name]; + } + if (!class_exists($name)) { + if (!isset($servicedir)) { + $servicedir = dirname(__FILE__) .'/'; + } + require_once($servicedir . strtolower($name) . '.php'); + } + $instances[$name] = call_user_func(array($name, 'getInstance'), $db); + } + return $instances[$name]; + } +} +?>
\ No newline at end of file |