/[cvs]/nfo/php/libs/org.netfrag.glib/Class/Inner.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.glib/Class/Inner.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations)
Wed Jul 21 12:59:09 2004 UTC (19 years, 11 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +9 -3 lines
minor change: name of parent-reference should be lower case (php5)

1 <?
2 /**
3 * This file contains the Class::Inner class.
4 *
5 * @author Andreas Motl <andreas.motl@ilo.de>
6 * @package org.netfrag.glib
7 * @name Class::Inner
8 *
9 */
10
11 /**
12 * <b>Cvs-Log:</b>
13 *
14 * <pre>
15 * $Id: Inner.php,v 1.8 2003/03/28 03:03:49 joko Exp $
16 *
17 * $Log: Inner.php,v $
18 * Revision 1.8 2003/03/28 03:03:49 joko
19 * purged old code
20 *
21 * Revision 1.7 2003/03/11 02:28:11 joko
22 * + fixed metadata for phpDocumentor
23 *
24 * Revision 1.6 2003/03/11 02:23:02 joko
25 * + fixed metadata for phpDocumentor
26 *
27 * Revision 1.5 2003/03/11 02:04:36 joko
28 * + fixed metadata for phpDocumentor
29 *
30 * Revision 1.4 2003/03/11 01:42:59 joko
31 * + fixed metadata for phpDocumentor
32 *
33 * 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 * </pre>
59 *
60 */
61
62 /**
63 * This requires DesignPattern::Facade as a base class
64 *
65 */
66 loadModule('DesignPattern::Facade');
67
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 * @package org.netfrag.glib
79 * @subpackage Class
80 * @name Class::Inner
81 *
82 */
83 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 //print "<hr/>" . Dumper($args);
109
110 foreach ($args[class_names] as $classname_inner) {
111
112 //print $classname_inner . "<br/>";
113
114 // build objectname from classname
115 // - make lowercase
116 // - strip leading "Xyz_" ('Site_' here)
117 $objectname = $classname_inner;
118 $objectname = str_replace('Site_', '', $objectname); // FIXME!!!
119 $objectname = strtolower($objectname);
120
121 // create new instance of helper object by classname
122 // V1:
123 //$this->$objectname = &$this->_mkInstance($classname_inner);
124
125 // V2:
126
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
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 $parent_name = strtolower($args[parent_name]);
149 $this->$objectname->$parent_name = &$this;
150
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 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed