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