X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FDAO%2FFactory.php;h=519f4c4341aa6355d059f0809f0c0d42892027dd;hb=4a3c7961f8c578506bdc6b8c0909b1ea435a9739;hp=b389988335fd08c08063222159a0170ef23516eb;hpb=a5d44edbee5498fa4195c5f3571db6b820185fa8;p=civicrm-core.git diff --git a/CRM/Core/DAO/Factory.php b/CRM/Core/DAO/Factory.php index b389988335..519f4c4341 100644 --- a/CRM/Core/DAO/Factory.php +++ b/CRM/Core/DAO/Factory.php @@ -5,7 +5,7 @@ */ class CRM_Core_DAO_Factory { - static $_classes = array( + public static $_classes = [ 'Domain' => 'data', 'Country' => 'singleton', 'County' => 'singleton', @@ -13,40 +13,36 @@ class CRM_Core_DAO_Factory { '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 $className + * @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; } + }