Merge pull request #4295 from eileenmcnaughton/CRM-15408
[civicrm-core.git] / CRM / Contact / DAO / Factory.php
index d4b89050efcfa1a01e50613cdcf5c0a6dded0f0e..419885a19dd893dcec6880cfdac1ad0d41e84bec 100644 (file)
@@ -23,21 +23,7 @@ class CRM_Contact_DAO_Factory {
 
   static $_suffix = '.php';
 
-  static $_preCall = array(
-    'singleton' => '',
-    'business' => 'new',
-    'data' => 'new',
-  );
-
-  static $_extCall = array(
-    'singleton' => '::singleton',
-    'business' => '',
-    'data' => '',
-  );
-
-
-  static
-  function &create($className) {
+  static function &create($className) {
     $type = CRM_Utils_Array::value($className, self::$_classes);
     if (!$type) {
       return CRM_Core_DAO_Factory::create($className);
@@ -48,13 +34,14 @@ class CRM_Contact_DAO_Factory {
 
     require_once ($file . self::$_suffix);
 
-    $newObj = eval(sprintf("return %s %s%s();",
-        self::$_preCall[$type],
-        $class,
-        self::$_extCall[$type]
-      ));
+    if ($type == 'singleton') {
+      $newObj = $class::singleton();
+    }
+    else {
+      // this is either 'business' or 'data'
+      $newObj = new $class;
+    }
 
     return $newObj;
   }
 }
-