1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: 18: 19: 20: 21: 22:
23: class cCodeGeneratorFactory {
24:
25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36:
37: public static function getInstance($name = '') {
38: global $cfg;
39:
40: if ($name == '') {
41: $name = $cfg['code_generator']['name'];
42: }
43:
44: if ($name == 'Factory' || $name == 'Abstract') {
45: throw new cInvalidArgumentException('Invalid name passed to cCodeGeneratorFactory: ' . $name . '!');
46: }
47:
48: $className = 'cCodeGenerator' . $name;
49: if (!class_exists($className)) {
50: $fileName = $name . '.class.php';
51: $path = str_replace('\\', '/', dirname(__FILE__)) . '/';
52: if (!cFileHandler::exists($path . $fileName)) {
53: throw new cInvalidArgumentException('The classfile couldn\'t included by cCodeGeneratorFactory: ' . $name . '!');
54: }
55:
56: include_once($path . $fileName);
57: if (!class_exists($className)) {
58: throw new cInvalidArgumentException('The class isn\'t available for cCodeGeneratorFactory: ' . $name . '!');
59: }
60: }
61:
62: return new $className();
63: }
64:
65: }
66: