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