| 3 | //  $Id$ | //  $Id$ | 
| 4 | // --------------------------------------------------------------------------- | // --------------------------------------------------------------------------- | 
| 5 | //  $Log$ | //  $Log$ | 
| 6 |  | //  Revision 1.6  2003/02/28 04:18:13  joko | 
| 7 |  | //  + special-case-handling for single argument pass-in | 
| 8 |  | //  + testing with constructor autocalling: not used for now since weird sideeffects occoured! | 
| 9 |  | //     o however: rethink it completely! | 
| 10 |  | // | 
| 11 |  | //  Revision 1.5  2003/02/27 16:36:02  joko | 
| 12 |  | //  re-allowed underscores ('_') in php classnames | 
| 13 |  | //  does this break something? | 
| 14 |  | // | 
| 15 |  | //  Revision 1.4  2003/02/22 16:34:16  joko | 
| 16 |  | //  + minor fix: can seperate namespace identifier with slashes ('/') now | 
| 17 |  | // | 
| 18 |  | //  Revision 1.3  2003/02/09 17:16:06  joko | 
| 19 |  | //  + handling arguments perl style ;-) | 
| 20 |  | // | 
| 21 | //  Revision 1.2  2003/02/03 05:01:48  joko | //  Revision 1.2  2003/02/03 05:01:48  joko | 
| 22 | //  + now attributes can get passed in to the constructors | //  + now attributes can get passed in to the constructors | 
| 23 | // | // | 
| 27 | // --------------------------------------------------------------------------- | // --------------------------------------------------------------------------- | 
| 28 |  |  | 
| 29 |  |  | 
|  |  |  | 
| 30 | /* | /* | 
| 31 | class DesignPattern_Object { | class DesignPattern_Object { | 
| 32 | function DesignPattern_Object() { | function DesignPattern_Object() { | 
| 42 | } | } | 
| 43 | } | } | 
| 44 |  |  | 
| 45 | function mkObject($namespacedClassname, $attributes = null) { | function mkObject() { | 
| 46 |  | $arg_list = func_get_args(); | 
| 47 |  |  | 
| 48 |  | // patch arglist if all arguments are passed in as a single array | 
| 49 |  | if (count($arg_list) == 1 && is_array($arg_list[0])) { | 
| 50 |  | $arg_list = $arg_list[0]; | 
| 51 |  | } | 
| 52 |  |  | 
| 53 |  | //print Dumper($arg_list); | 
| 54 |  | $namespacedClassname = array_shift($arg_list); | 
| 55 |  | if (strstr($namespacedClassname, '_')) { | 
| 56 |  | //print "mkObject: unallowed character in namespaced classname: '_' ($namespacedClassname)<br/>"; | 
| 57 |  | //return; | 
| 58 |  | } | 
| 59 |  | //print "class: $classname<br>"; | 
| 60 |  | $attributes = $arg_list; | 
| 61 | $classname = $namespacedClassname; | $classname = $namespacedClassname; | 
| 62 | if (loadModule($namespacedClassname)) { | if (loadModule($namespacedClassname)) { | 
| 63 | $classname = str_replace('::', '_', $namespacedClassname); | $classname = str_replace('::', '_', $namespacedClassname); | 
| 64 |  | $classname = str_replace('/', '_', $classname); | 
| 65 | } | } | 
| 66 | $obj = new DesignPattern_Bridge($classname, $attributes); | $obj = new DesignPattern_Bridge($classname, $attributes); | 
| 67 |  |  | 
| 68 |  | // call constructor if possible | 
| 69 |  | // FIXME: take care for side-effects!!! | 
| 70 |  | /* | 
| 71 |  | if (method_exists($obj, 'constructor')) { | 
| 72 |  | $obj->constructor(); | 
| 73 |  | } | 
| 74 |  | */ | 
| 75 |  |  | 
| 76 | return $obj; | return $obj; | 
| 77 | } | } | 
| 78 |  |  |