3 |
* This file contains the Class::Inner class. |
* This file contains the Class::Inner class. |
4 |
* |
* |
5 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
|
* @package org.netfrag.glib |
7 |
* @name Class::Inner |
* @name Class::Inner |
8 |
* |
* |
9 |
*/ |
*/ |
10 |
|
|
11 |
|
/** |
12 |
// --------------------------------------------------------------------------- |
* <b>Cvs-Log:</b> |
13 |
// $Id$ |
* |
14 |
// --------------------------------------------------------------------------- |
* <pre> |
15 |
// $Log$ |
* $Id$ |
16 |
// Revision 1.2 2003/03/05 18:54:43 joko |
* |
17 |
// updated docu - phpDocumentor is very strict about its 'blocks'... |
* $Log$ |
18 |
// |
* Revision 1.8 2003/03/28 03:03:49 joko |
19 |
// Revision 1.1 2003/03/03 21:26:30 joko |
* purged old code |
20 |
// refactored from DesignPattern::Bridge |
* |
21 |
// |
* Revision 1.7 2003/03/11 02:28:11 joko |
22 |
// Revision 1.5 2003/02/27 18:09:56 joko |
* + fixed metadata for phpDocumentor |
23 |
// mungled mechanism to shift in and pass on arguments |
* |
24 |
// |
* Revision 1.6 2003/03/11 02:23:02 joko |
25 |
// Revision 1.4 2003/02/09 17:07:53 joko |
* + fixed metadata for phpDocumentor |
26 |
// + minor update related to new log level constants |
* |
27 |
// + generic argument merger to show full constructor args |
* Revision 1.5 2003/03/11 02:04:36 joko |
28 |
// |
* + fixed metadata for phpDocumentor |
29 |
// Revision 1.3 2003/02/03 14:46:57 joko |
* |
30 |
// + wrapped calls to available initializers (constructors, declared startup methods) |
* Revision 1.4 2003/03/11 01:42:59 joko |
31 |
// - moved logger-code to DesignPattern::Logger |
* + fixed metadata for phpDocumentor |
32 |
// |
* |
33 |
// Revision 1.2 2003/02/03 05:01:27 joko |
* Revision 1.3 2003/03/11 01:12:53 joko |
34 |
// + now attributes can get passed in to the constructors |
* + fixed metadata for phpDocumentor |
35 |
// |
* |
36 |
// Revision 1.1 2003/02/03 03:33:48 joko |
* Revision 1.2 2003/03/05 18:54:43 joko |
37 |
// + initial commit |
* updated docu - phpDocumentor is very strict about its 'blocks'... |
38 |
// |
* |
39 |
// --------------------------------------------------------------------------- |
* Revision 1.1 2003/03/03 21:26:30 joko |
40 |
|
* refactored from DesignPattern::Bridge |
41 |
|
* |
42 |
|
* Revision 1.5 2003/02/27 18:09:56 joko |
43 |
|
* mungled mechanism to shift in and pass on arguments |
44 |
|
* |
45 |
|
* Revision 1.4 2003/02/09 17:07:53 joko |
46 |
|
* + minor update related to new log level constants |
47 |
|
* + generic argument merger to show full constructor args |
48 |
|
* |
49 |
|
* Revision 1.3 2003/02/03 14:46:57 joko |
50 |
|
* + wrapped calls to available initializers (constructors, declared startup methods) |
51 |
|
* - moved logger-code to DesignPattern::Logger |
52 |
|
* |
53 |
|
* Revision 1.2 2003/02/03 05:01:27 joko |
54 |
|
* + now attributes can get passed in to the constructors |
55 |
|
* |
56 |
|
* Revision 1.1 2003/02/03 03:33:48 joko |
57 |
|
* + initial commit |
58 |
|
* </pre> |
59 |
|
* |
60 |
|
*/ |
61 |
|
|
62 |
/** |
/** |
63 |
* This requires DesignPattern::Facade as a base class |
* This requires DesignPattern::Facade as a base class |
107 |
|
|
108 |
//print Dumper($args); |
//print Dumper($args); |
109 |
|
|
110 |
foreach ($args[class_names] as $classname) { |
foreach ($args[class_names] as $classname_inner) { |
111 |
|
|
112 |
// build objectname from classname |
// build objectname from classname |
113 |
// - make lowercase |
// - make lowercase |
114 |
// - strip leading "Xyz_" ('Site_' here) |
// - strip leading "Xyz_" ('Site_' here) |
115 |
$objectname = $classname; |
$objectname = $classname_inner; |
116 |
$objectname = str_replace('Site_', '', $objectname); // FIXME!!! |
$objectname = str_replace('Site_', '', $objectname); // FIXME!!! |
117 |
$objectname = strtolower($objectname); |
$objectname = strtolower($objectname); |
118 |
|
|
119 |
// create new instance of helper object by classname |
// create new instance of helper object by classname |
120 |
// V1: |
// V1: |
121 |
//$this->$objectname = &$this->_mkInstance($classname); |
//$this->$objectname = &$this->_mkInstance($classname_inner); |
122 |
|
|
123 |
// V2: |
// V2: |
124 |
$this->$objectname = &php::mkInstance($classname); |
|
125 |
|
/** |
126 |
|
* <!-- Autodia --> |
127 |
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
128 |
|
* $this->_locator = new $classname_inner() |
129 |
|
* |
130 |
|
*/ |
131 |
|
|
132 |
|
$this->$objectname = &php::mkInstance($classname_inner); |
133 |
|
|
134 |
// create additional references to helper object with other names if requested |
// create additional references to helper object with other names if requested |
135 |
// the intention is (e.g.) to migrate objects over to new reference-names when development progresses and ... |
// the intention is (e.g.) to migrate objects over to new reference-names when development progresses and ... |
154 |
|
|
155 |
} |
} |
156 |
|
|
|
|
|
|
|
|
|
// --- old code |
|
|
|
|
|
function DesignPattern_Bridge_old() { |
|
|
|
|
|
$arg_list = func_get_args(); |
|
|
$classname = array_shift($arg_list); |
|
|
|
|
|
// expand single argument |
|
|
if (count($arg_list) == 1) { |
|
|
$arg_list = $arg_list[0]; |
|
|
} |
|
|
$attributes = &$arg_list; |
|
|
|
|
|
//print Dumper($attributes); |
|
|
|
|
|
//print "init_bridge!<br>"; |
|
|
//return $this->_mkInstance($classname, $attributes); |
|
|
//$this->_init_logger("../core/var/log/logfile.txt", 1); |
|
|
//parent::constructor(); |
|
|
|
|
|
// V1: |
|
|
$this = $this->_mkInstance($classname, $attributes); |
|
|
// V2: (don't do that - will crash your apache!!! - hehe - it's an infinite loop) |
|
|
//$this = php::mkInstance($classname, $attributes); |
|
|
|
|
|
//parent::constructor(); |
|
|
// $this->_init_logger("../core/var/log/logfile.txt", 1); |
|
|
//print Dumper($this); |
|
|
|
|
|
//return $this; |
|
|
} |
|
|
|
|
|
function &_mkInstance_old($classname, $attributes = null) { |
|
|
parent::constructor(); |
|
|
$this->log( get_class($this) . "->_mkInstance( classname $classname )" ); |
|
|
if (isset($attributes)) { |
|
|
//print Dumper($attributes); |
|
|
|
|
|
/* |
|
|
// pass single argument 1:1 |
|
|
if (count($attributes) == 1) { |
|
|
$attributes_merged = $attributes[0]; |
|
|
|
|
|
|
|
|
|
|
|
// pass hash 1:1 |
|
|
} elseif (is_hash($attributes)) { |
|
|
$attributes_merged = $attributes; |
|
|
|
|
|
} else { |
|
|
$attributes_merged = $attributes; |
|
|
} |
|
|
*/ |
|
|
|
|
|
$args_pass = array(); |
|
|
for ($i=0; $i<=count($attributes); $i++) { |
|
|
array_push($args_pass, '$attributes[' . $i . ']'); |
|
|
} |
|
|
|
|
|
$arg_string = join(', ', $args_pass); |
|
|
|
|
|
/* |
|
|
// merge entries of numerical indexed arrays together into one hash |
|
|
} else { |
|
|
$attributes_merged = array(); |
|
|
foreach ($attributes as $entry) { |
|
|
$attributes_merged = array_merge($attributes_merged, $entry); |
|
|
} |
|
|
} |
|
|
*/ |
|
|
|
|
|
//print Dumper($attributes_merged); |
|
|
//print Dumper($attributes); |
|
|
//$instance = new $classname($attributes_merged); |
|
|
//$instance = new $classname($attributes[0]); |
|
|
$evalstr = 'return new $classname(' . $arg_string . ');'; |
|
|
$instance = eval($evalstr); |
|
|
//print $evalstr . "<br>"; |
|
|
} else { |
|
|
$instance = new $classname; |
|
|
} |
|
|
//$this->log("ok"); |
|
|
return $instance; |
|
|
} |
|
157 |
|
|
158 |
} |
} |
159 |
|
|
|
|
|
|
|
|
|
|
|
160 |
?> |
?> |