*/
class CRM_Contact_DAO_Factory {
- static $_classes = array(
+ public static $_classes = [
'Address' => 'data',
'Contact' => 'data',
'Email' => 'data',
'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) {
+ public static function create($className) {
$type = CRM_Utils_Array::value($className, self::$_classes);
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;
}
+
}
*/
class CRM_Core_DAO_Factory {
- static $_classes = array(
+ public static $_classes = [
'Domain' => 'data',
'Country' => 'singleton',
'County' => 'singleton',
'GeoCoord' => 'singleton',
'IMProvider' => 'singleton',
'MobileProvider' => 'singleton',
- );
+ ];
- static $_prefix = array(
- 'business' => 'CRM/Core/BAO/',
- 'data' => 'CRM/Core/DAO/',
- );
-
- static $_suffix = '.php';
+ public static $_prefix = [
+ 'business' => 'CRM_Core_BAO_',
+ 'data' => 'CRM_Core_DAO_',
+ ];
/**
* @param string $className
* @return mixed
* @throws Exception
*/
- static function &create($className) {
+ public static function create($className) {
$type = CRM_Utils_Array::value($className, self::$_classes);
if (!$type) {
CRM_Core_Error::fatal("class $className not found");
}
- $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;
}
+
}