Display public title and description on profiles and unsubscribe/subscribe forms...
[civicrm-core.git] / CRM / Contact / DAO / Factory.php
index 5f4432c2b50fd3298cdc4d312bfcdd376aaf61bc..ef11dad723c04871c8781a5816ccae53203ba325 100644 (file)
@@ -5,7 +5,7 @@
  */
 class CRM_Contact_DAO_Factory {
 
-  static $_classes = array(
+  public static $_classes = [
     'Address' => 'data',
     'Contact' => 'data',
     'Email' => 'data',
@@ -17,39 +17,35 @@ class CRM_Contact_DAO_Factory {
     'Organization' => 'data',
     'Phone' => 'data',
     'Relationship' => 'data',
-  );
+  ];
 
-  static $_prefix = array(
-    'business' => 'CRM/Contact/BAO/',
-    'data' => 'CRM/Contact/DAO/',
-  );
-
-  static $_suffix = '.php';
+  public static $_prefix = [
+    'business' => 'CRM_Contact_BAO_',
+    'data' => 'CRM_Contact_DAO_',
+  ];
 
   /**
    * @param string $className
    *
    * @return mixed
    */
-  static function &create($className) {
-    $type = CRM_Utils_Array::value($className, self::$_classes);
+  public static function create($className) {
+    $type = self::$_classes[$className] ?? NULL;
     if (!$type) {
       return CRM_Core_DAO_Factory::create($className);
     }
 
-    $file = self::$_prefix[$type] . $className;
-    $class = str_replace('/', '_', $file);
-
-    require_once($file . self::$_suffix);
+    $class = self::$_prefix[$type] . $className;
 
     if ($type == 'singleton') {
       $newObj = $class::singleton();
     }
     else {
       // this is either 'business' or 'data'
-      $newObj = new $class;
+      $newObj = new $class();
     }
 
     return $newObj;
   }
+
 }