aboutsummaryrefslogtreecommitdiff
path: root/services/servicefactory.php
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-21 11:22:40 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-21 11:22:40 +0000
commit9d22fdc36f6257de021f36b26ce33eba99d41dc0 (patch)
tree3688465b99226d20751130a1cb5acb84f53009d1 /services/servicefactory.php
parent5db18a09c4eca4560c117f0b4dcd85d75e7139f2 (diff)
downloadsemanticscuttle-9d22fdc36f6257de021f36b26ce33eba99d41dc0.tar.gz
semanticscuttle-9d22fdc36f6257de021f36b26ce33eba99d41dc0.tar.bz2
Minor refactoring
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@170 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'services/servicefactory.php')
-rw-r--r--services/servicefactory.php60
1 files changed, 30 insertions, 30 deletions
diff --git a/services/servicefactory.php b/services/servicefactory.php
index 7ff7f22..f4d6af7 100644
--- a/services/servicefactory.php
+++ b/services/servicefactory.php
@@ -1,35 +1,35 @@
<?php
-/* Build services */
+/* Connect to the database and build services */
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];
- }
+ 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];
+ }
}
?>