CRM-20312 regenerated DAO with localisation
[civicrm-core.git] / CRM / Contact / DAO / Factory.php
CommitLineData
6a488035 1<?php
6a488035 2
86538308
EM
3/**
4 * Class CRM_Contact_DAO_Factory
5 */
6a488035
TO
6class CRM_Contact_DAO_Factory {
7
8 static $_classes = array(
9 'Address' => 'data',
10 'Contact' => 'data',
11 'Email' => 'data',
12 'Household' => 'data',
13 'IM' => 'data',
14 'Individual' => 'data',
15 'Location' => 'data',
16 'LocationType' => 'data',
17 'Organization' => 'data',
18 'Phone' => 'data',
19 'Relationship' => 'data',
20 );
21
22 static $_prefix = array(
23 'business' => 'CRM/Contact/BAO/',
24 'data' => 'CRM/Contact/DAO/',
25 );
26
27 static $_suffix = '.php';
28
86538308 29 /**
100fef9d 30 * @param string $className
86538308
EM
31 *
32 * @return mixed
33 */
0e6e8724 34 static function &create($className) {
6a488035
TO
35 $type = CRM_Utils_Array::value($className, self::$_classes);
36 if (!$type) {
37 return CRM_Core_DAO_Factory::create($className);
38 }
39
40 $file = self::$_prefix[$type] . $className;
41 $class = str_replace('/', '_', $file);
42
353ffa53 43 require_once($file . self::$_suffix);
6a488035 44
0e6e8724
DL
45 if ($type == 'singleton') {
46 $newObj = $class::singleton();
47 }
48 else {
49 // this is either 'business' or 'data'
50 $newObj = new $class;
51 }
6a488035
TO
52
53 return $newObj;
54 }
55}