--- nfo/php/libs/org.netfrag.glib/Class/Inner.php 2003/03/11 02:28:11 1.7 +++ nfo/php/libs/org.netfrag.glib/Class/Inner.php 2004/07/21 12:59:09 1.9 @@ -12,9 +12,15 @@ * Cvs-Log: * *
- *  $Id: Inner.php,v 1.7 2003/03/11 02:28:11 joko Exp $
+ *  $Id: Inner.php,v 1.9 2004/07/21 12:59:09 joko Exp $
  *
  *  $Log: Inner.php,v $
+ *  Revision 1.9  2004/07/21 12:59:09  joko
+ *  minor change: name of parent-reference should be lower case (php5)
+ *
+ *  Revision 1.8  2003/03/28 03:03:49  joko
+ *  purged old code
+ *
  *  Revision 1.7  2003/03/11 02:28:11  joko
  *  + fixed metadata for phpDocumentor
  *
@@ -102,22 +108,33 @@
     $this->log( get_parent_class($this) . "->__create_inners( parent='" . $args[parent_name] . "' )", PEAR_LOG_INFO );
     //$this->log( get_parent_class($this) . "->_init_helpers: instantiating helper objects below '" . get_class($this) . "::'" );
 
-//print Dumper($args);
+//print "
" . Dumper($args); - foreach ($args[class_names] as $classname) { + foreach ($args[class_names] as $classname_inner) { + + //print $classname_inner . "
"; // build objectname from classname // - make lowercase // - strip leading "Xyz_" ('Site_' here) - $objectname = $classname; + $objectname = $classname_inner; $objectname = str_replace('Site_', '', $objectname); // FIXME!!! $objectname = strtolower($objectname); // create new instance of helper object by classname // V1: - //$this->$objectname = &$this->_mkInstance($classname); + //$this->$objectname = &$this->_mkInstance($classname_inner); + // V2: - $this->$objectname = &php::mkInstance($classname); + + /** + * + * can do: (this is metadata supplied for Autodia, don't delete!) + * $this->_locator = new $classname_inner() + * + */ + + $this->$objectname = &php::mkInstance($classname_inner); // create additional references to helper object with other names if requested // the intention is (e.g.) to migrate objects over to new reference-names when development progresses and ... @@ -131,7 +148,8 @@ } // helper gets reference to ourselves as a parent - $this->$objectname->$args[parent_name] = &$this; + $parent_name = strtolower($args[parent_name]); + $this->$objectname->$parent_name = &$this; $this->__call_constructor($objectname, 'constructor'); if ( $method = $args[run] ) { @@ -142,96 +160,7 @@ } - - -// --- 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!
"; - //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 . "
"; - } else { - $instance = new $classname; - } - //$this->log("ok"); - return $instance; - } } - - - ?> \ No newline at end of file