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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Mon Mar 3 21:26:30 2003 UTC revision 1.9 by joko, Wed Jul 21 12:59:09 2004 UTC
# Line 1  Line 1 
1  <?  <?
2  // ---------------------------------------------------------------------------  /**
3  //  $Id$   * This file contains the Class::Inner class.
4  // ---------------------------------------------------------------------------   *
5  //  $Log$   * @author Andreas Motl <andreas.motl@ilo.de>
6  //  Revision 1.1  2003/03/03 21:26:30  joko   * @package org.netfrag.glib
7  //  refactored from DesignPattern::Bridge   * @name Class::Inner
8  //   *
9  //  Revision 1.5  2003/02/27 18:09:56  joko   */
10  //  mungled mechanism to shift in and pass on arguments  
11  //  /**
12  //  Revision 1.4  2003/02/09 17:07:53  joko   * <b>Cvs-Log:</b>
13  //  + minor update related to new log level constants   *
14  //  + generic argument merger to show full constructor args   * <pre>
15  //   *  $Id$
16  //  Revision 1.3  2003/02/03 14:46:57  joko   *
17  //  + wrapped calls to available initializers (constructors, declared startup methods)   *  $Log$
18  //  - moved logger-code to DesignPattern::Logger   *  Revision 1.9  2004/07/21 12:59:09  joko
19  //   *  minor change: name of parent-reference should be lower case (php5)
20  //  Revision 1.2  2003/02/03 05:01:27  joko   *
21  //  + now attributes can get passed in to the constructors   *  Revision 1.8  2003/03/28 03:03:49  joko
22  //   *  purged old code
23  //  Revision 1.1  2003/02/03 03:33:48  joko   *
24  //  + initial commit   *  Revision 1.7  2003/03/11 02:28:11  joko
25  //   *  + fixed metadata for phpDocumentor
26  // ---------------------------------------------------------------------------   *
27     *  Revision 1.6  2003/03/11 02:23:02  joko
28     *  + fixed metadata for phpDocumentor
29     *
30     *  Revision 1.5  2003/03/11 02:04:36  joko
31     *  + fixed metadata for phpDocumentor
32     *
33     *  Revision 1.4  2003/03/11 01:42:59  joko
34     *  + fixed metadata for phpDocumentor
35     *
36     *  Revision 1.3  2003/03/11 01:12:53  joko
37     *  + fixed metadata for phpDocumentor
38     *
39     *  Revision 1.2  2003/03/05 18:54:43  joko
40     *  updated docu - phpDocumentor is very strict about its 'blocks'...
41     *
42     *  Revision 1.1  2003/03/03 21:26:30  joko
43     *  refactored from DesignPattern::Bridge
44     *
45     *  Revision 1.5  2003/02/27 18:09:56  joko
46     *  mungled mechanism to shift in and pass on arguments
47     *
48     *  Revision 1.4  2003/02/09 17:07:53  joko
49     *  + minor update related to new log level constants
50     *  + generic argument merger to show full constructor args
51     *
52     *  Revision 1.3  2003/02/03 14:46:57  joko
53     *  + wrapped calls to available initializers (constructors, declared startup methods)
54     *  - moved logger-code to DesignPattern::Logger
55     *
56     *  Revision 1.2  2003/02/03 05:01:27  joko
57     *  + now attributes can get passed in to the constructors
58     *
59     *  Revision 1.1  2003/02/03 03:33:48  joko
60     *  + initial commit
61     * </pre>
62     *
63     */
64    
65    /**
66     * This requires DesignPattern::Facade as a base class
67     *
68     */
69  loadModule('DesignPattern::Facade');  loadModule('DesignPattern::Facade');
70    
71    /**
72     * Class::Inner
73     *
74     * @author Andreas Motl <andreas.motl@ilo.de>
75     * @copyright (c) 2003 - All Rights reserved.
76     * @license GNU LGPL (GNU Lesser General Public License)
77     *
78     * @link http://www.netfrag.org/~joko/
79     * @link http://www.gnu.org/licenses/lgpl.txt
80     *
81     * @package org.netfrag.glib
82     * @subpackage Class
83     * @name Class::Inner
84     *
85     */
86  class Class_Inner extends DesignPattern_Facade {  class Class_Inner extends DesignPattern_Facade {
87    
88    /*    /*
# Line 52  class Class_Inner extends DesignPattern_ Line 108  class Class_Inner extends DesignPattern_
108      $this->log( get_parent_class($this) . "->__create_inners( parent='" . $args[parent_name] . "' )", PEAR_LOG_INFO );      $this->log( get_parent_class($this) . "->__create_inners( parent='" . $args[parent_name] . "' )", PEAR_LOG_INFO );
109      //$this->log( get_parent_class($this) . "->_init_helpers: instantiating helper objects below '" . get_class($this) . "::'" );      //$this->log( get_parent_class($this) . "->_init_helpers: instantiating helper objects below '" . get_class($this) . "::'" );
110    
111  //print Dumper($args);  //print "<hr/>" . Dumper($args);
112    
113      foreach ($args[class_names] as $classname) {      foreach ($args[class_names] as $classname_inner) {
114          
115          //print $classname_inner . "<br/>";
116                
117        // build objectname from classname        // build objectname from classname
118        //  - make lowercase        //  - make lowercase
119        // - strip leading "Xyz_" ('Site_' here)        // - strip leading "Xyz_" ('Site_' here)
120        $objectname = $classname;        $objectname = $classname_inner;
121        $objectname = str_replace('Site_', '', $objectname);      // FIXME!!!        $objectname = str_replace('Site_', '', $objectname);      // FIXME!!!
122        $objectname = strtolower($objectname);        $objectname = strtolower($objectname);
123    
124        // create new instance of helper object by classname        // create new instance of helper object by classname
125        // V1:        // V1:
126        //$this->$objectname = &$this->_mkInstance($classname);        //$this->$objectname = &$this->_mkInstance($classname_inner);
127    
128        // V2:        // V2:
129        $this->$objectname = &php::mkInstance($classname);  
130          /**
131           * <!-- Autodia -->
132           * can do: (this is metadata supplied for Autodia, don't delete!)
133           *  $this->_locator = new $classname_inner()
134           *
135           */
136    
137          $this->$objectname = &php::mkInstance($classname_inner);
138                
139        // create additional references to helper object with other names if requested        // create additional references to helper object with other names if requested
140        // 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 ...
# Line 81  class Class_Inner extends DesignPattern_ Line 148  class Class_Inner extends DesignPattern_
148        }        }
149    
150        // helper gets reference to ourselves as a parent        // helper gets reference to ourselves as a parent
151        $this->$objectname->$args[parent_name] = &$this;        $parent_name = strtolower($args[parent_name]);
152          $this->$objectname->$parent_name = &$this;
153        
154        $this->__call_constructor($objectname, 'constructor');        $this->__call_constructor($objectname, 'constructor');
155        if ( $method = $args[run] ) {        if ( $method = $args[run] ) {
# Line 92  class Class_Inner extends DesignPattern_ Line 160  class Class_Inner extends DesignPattern_
160        
161    }    }
162    
     
   
 // --- 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;  
   }  
163    
164  }  }
165    
   
   
   
166  ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.9

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