projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #14059 from Stoob/patch-2
[civicrm-core.git]
/
CRM
/
Core
/
DAO
/
Factory.php
diff --git
a/CRM/Core/DAO/Factory.php
b/CRM/Core/DAO/Factory.php
index a40b31d0342fbf5354465de3b9462025570564f7..519f4c4341aa6355d059f0809f0c0d42892027dd 100644
(file)
--- a/
CRM/Core/DAO/Factory.php
+++ b/
CRM/Core/DAO/Factory.php
@@
-5,7
+5,7
@@
*/
class CRM_Core_DAO_Factory {
*/
class CRM_Core_DAO_Factory {
- static $_classes = array(
+ public static $_classes = [
'Domain' => 'data',
'Country' => 'singleton',
'County' => 'singleton',
'Domain' => 'data',
'Country' => 'singleton',
'County' => 'singleton',
@@
-13,14
+13,12
@@
class CRM_Core_DAO_Factory {
'GeoCoord' => 'singleton',
'IMProvider' => 'singleton',
'MobileProvider' => '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
/**
* @param string $className
@@
-28,25
+26,23
@@
class CRM_Core_DAO_Factory {
* @return mixed
* @throws Exception
*/
* @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");
}
$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'
if ($type == 'singleton') {
$newObj = $class::singleton();
}
else {
// this is either 'business' or 'data'
- $newObj = new $class;
+ $newObj = new $class
()
;
}
return $newObj;
}
}
return $newObj;
}
+
}
}