Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | class CRM_Contact_DAO_Factory { | |
4 | ||
5 | static $_classes = array( | |
6 | 'Address' => 'data', | |
7 | 'Contact' => 'data', | |
8 | 'Email' => 'data', | |
9 | 'Household' => 'data', | |
10 | 'IM' => 'data', | |
11 | 'Individual' => 'data', | |
12 | 'Location' => 'data', | |
13 | 'LocationType' => 'data', | |
14 | 'Organization' => 'data', | |
15 | 'Phone' => 'data', | |
16 | 'Relationship' => 'data', | |
17 | ); | |
18 | ||
19 | static $_prefix = array( | |
20 | 'business' => 'CRM/Contact/BAO/', | |
21 | 'data' => 'CRM/Contact/DAO/', | |
22 | ); | |
23 | ||
24 | static $_suffix = '.php'; | |
25 | ||
0e6e8724 | 26 | static function &create($className) { |
6a488035 TO |
27 | $type = CRM_Utils_Array::value($className, self::$_classes); |
28 | if (!$type) { | |
29 | return CRM_Core_DAO_Factory::create($className); | |
30 | } | |
31 | ||
32 | $file = self::$_prefix[$type] . $className; | |
33 | $class = str_replace('/', '_', $file); | |
34 | ||
35 | require_once ($file . self::$_suffix); | |
36 | ||
0e6e8724 DL |
37 | if ($type == 'singleton') { |
38 | $newObj = $class::singleton(); | |
39 | } | |
40 | else { | |
41 | // this is either 'business' or 'data' | |
42 | $newObj = new $class; | |
43 | } | |
6a488035 TO |
44 | |
45 | return $newObj; | |
46 | } | |
47 | } |