1 |
joko |
1.1 |
<? |
2 |
joko |
1.2 |
/** |
3 |
|
|
* This file contains the Class::Inner class. |
4 |
|
|
* |
5 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
joko |
1.3 |
* @package org.netfrag.glib |
7 |
joko |
1.2 |
* @name Class::Inner |
8 |
|
|
* |
9 |
|
|
*/ |
10 |
|
|
|
11 |
joko |
1.4 |
/** |
12 |
joko |
1.7 |
* <b>Cvs-Log:</b> |
13 |
|
|
* |
14 |
joko |
1.4 |
* <pre> |
15 |
joko |
1.9 |
* $Id: Inner.php,v 1.8 2003/03/28 03:03:49 joko Exp $ |
16 |
joko |
1.6 |
* |
17 |
joko |
1.7 |
* $Log: Inner.php,v $ |
18 |
joko |
1.9 |
* Revision 1.8 2003/03/28 03:03:49 joko |
19 |
|
|
* purged old code |
20 |
|
|
* |
21 |
joko |
1.8 |
* Revision 1.7 2003/03/11 02:28:11 joko |
22 |
|
|
* + fixed metadata for phpDocumentor |
23 |
|
|
* |
24 |
joko |
1.7 |
* Revision 1.6 2003/03/11 02:23:02 joko |
25 |
|
|
* + fixed metadata for phpDocumentor |
26 |
joko |
1.5 |
* |
27 |
joko |
1.6 |
* Revision 1.5 2003/03/11 02:04:36 joko |
28 |
|
|
* + fixed metadata for phpDocumentor |
29 |
|
|
* |
30 |
joko |
1.5 |
* Revision 1.4 2003/03/11 01:42:59 joko |
31 |
|
|
* + fixed metadata for phpDocumentor |
32 |
|
|
* |
33 |
joko |
1.4 |
* Revision 1.3 2003/03/11 01:12:53 joko |
34 |
|
|
* + fixed metadata for phpDocumentor |
35 |
|
|
* |
36 |
|
|
* Revision 1.2 2003/03/05 18:54:43 joko |
37 |
|
|
* 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 |
joko |
1.5 |
* </pre> |
59 |
joko |
1.4 |
* |
60 |
|
|
*/ |
61 |
joko |
1.1 |
|
62 |
joko |
1.2 |
/** |
63 |
|
|
* This requires DesignPattern::Facade as a base class |
64 |
|
|
* |
65 |
|
|
*/ |
66 |
joko |
1.1 |
loadModule('DesignPattern::Facade'); |
67 |
joko |
1.2 |
|
68 |
|
|
/** |
69 |
|
|
* Class::Inner |
70 |
|
|
* |
71 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
72 |
|
|
* @copyright (c) 2003 - All Rights reserved. |
73 |
|
|
* @license GNU LGPL (GNU Lesser General Public License) |
74 |
|
|
* |
75 |
|
|
* @link http://www.netfrag.org/~joko/ |
76 |
|
|
* @link http://www.gnu.org/licenses/lgpl.txt |
77 |
|
|
* |
78 |
joko |
1.6 |
* @package org.netfrag.glib |
79 |
joko |
1.2 |
* @subpackage Class |
80 |
|
|
* @name Class::Inner |
81 |
|
|
* |
82 |
|
|
*/ |
83 |
joko |
1.1 |
class Class_Inner extends DesignPattern_Facade { |
84 |
|
|
|
85 |
|
|
/* |
86 |
|
|
var $_parent_class; |
87 |
|
|
var $_inner_classes; |
88 |
|
|
var $_inner_objects; |
89 |
|
|
var $_call_constructor; |
90 |
|
|
*/ |
91 |
|
|
|
92 |
|
|
function perform($args) { |
93 |
|
|
$this->__create_inners($args); |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
function __call_constructor($objectname, $method) { |
97 |
|
|
if (method_exists($this->$objectname, $method)) { |
98 |
|
|
$this->log( get_class($this) . "->__call_constructor: autocalling \$this->" . $objectname . "->$method()" ); |
99 |
|
|
$this->$objectname->$method(); |
100 |
|
|
} |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
function __create_inners($args) { |
104 |
|
|
|
105 |
|
|
$this->log( get_parent_class($this) . "->__create_inners( parent='" . $args[parent_name] . "' )", PEAR_LOG_INFO ); |
106 |
|
|
//$this->log( get_parent_class($this) . "->_init_helpers: instantiating helper objects below '" . get_class($this) . "::'" ); |
107 |
|
|
|
108 |
joko |
1.9 |
//print "<hr/>" . Dumper($args); |
109 |
joko |
1.1 |
|
110 |
joko |
1.8 |
foreach ($args[class_names] as $classname_inner) { |
111 |
joko |
1.1 |
|
112 |
joko |
1.9 |
//print $classname_inner . "<br/>"; |
113 |
|
|
|
114 |
joko |
1.1 |
// build objectname from classname |
115 |
|
|
// - make lowercase |
116 |
|
|
// - strip leading "Xyz_" ('Site_' here) |
117 |
joko |
1.8 |
$objectname = $classname_inner; |
118 |
joko |
1.1 |
$objectname = str_replace('Site_', '', $objectname); // FIXME!!! |
119 |
|
|
$objectname = strtolower($objectname); |
120 |
|
|
|
121 |
|
|
// create new instance of helper object by classname |
122 |
|
|
// V1: |
123 |
joko |
1.8 |
//$this->$objectname = &$this->_mkInstance($classname_inner); |
124 |
|
|
|
125 |
joko |
1.1 |
// V2: |
126 |
joko |
1.8 |
|
127 |
|
|
/** |
128 |
|
|
* <!-- Autodia --> |
129 |
|
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
130 |
|
|
* $this->_locator = new $classname_inner() |
131 |
|
|
* |
132 |
|
|
*/ |
133 |
|
|
|
134 |
|
|
$this->$objectname = &php::mkInstance($classname_inner); |
135 |
joko |
1.1 |
|
136 |
|
|
// create additional references to helper object with other names if requested |
137 |
|
|
// the intention is (e.g.) to migrate objects over to new reference-names when development progresses and ... |
138 |
|
|
// ... refactoring the object hierarchy is needed, but ... |
139 |
|
|
// ... you wanna provide the old reference names as "fallbacks" for old code using the libs |
140 |
|
|
if (is_array($args[ref_names])) { |
141 |
|
|
foreach ($args[ref_names] as $ref_name) { |
142 |
|
|
//print "mkRef: $ref_name<br>"; |
143 |
|
|
$this->$ref_name = &$this->$objectname; |
144 |
|
|
} |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
// helper gets reference to ourselves as a parent |
148 |
joko |
1.9 |
$parent_name = strtolower($args[parent_name]); |
149 |
|
|
$this->$objectname->$parent_name = &$this; |
150 |
joko |
1.1 |
|
151 |
|
|
$this->__call_constructor($objectname, 'constructor'); |
152 |
|
|
if ( $method = $args[run] ) { |
153 |
|
|
$this->__call_constructor($objectname, $method); |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
|
161 |
|
|
} |
162 |
|
|
|
163 |
|
|
?> |