/[cvs]/nfo/php/libs/org.netfrag.glib/DesignPattern/Bridge.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/DesignPattern/Bridge.php

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

revision 1.2 by joko, Mon Feb 3 05:01:27 2003 UTC revision 1.3 by joko, Mon Feb 3 14:46:57 2003 UTC
# Line 3  Line 3 
3  //  $Id$  //  $Id$
4  // ---------------------------------------------------------------------------  // ---------------------------------------------------------------------------
5  //  $Log$  //  $Log$
6    //  Revision 1.3  2003/02/03 14:46:57  joko
7    //  + wrapped calls to available initializers (constructors, declared startup methods)
8    //  - moved logger-code to DesignPattern::Logger
9    //
10  //  Revision 1.2  2003/02/03 05:01:27  joko  //  Revision 1.2  2003/02/03 05:01:27  joko
11  //  + now attributes can get passed in to the constructors  //  + now attributes can get passed in to the constructors
12  //  //
# Line 15  Line 19 
19  class DesignPattern_Bridge extends DesignPattern_Logger {  class DesignPattern_Bridge extends DesignPattern_Logger {
20    
21    function DesignPattern_Bridge($classname, $attributes = null) {    function DesignPattern_Bridge($classname, $attributes = null) {
22        //print "init_bridge!<br>";
23      //return $this->_mkInstance($classname, $attributes);      //return $this->_mkInstance($classname, $attributes);
24        //$this->_init_logger("../core/var/log/logfile.txt", 1);
25        //parent::constructor();
26      $this = $this->_mkInstance($classname, $attributes);      $this = $this->_mkInstance($classname, $attributes);
27        //parent::constructor();
28    //    $this->_init_logger("../core/var/log/logfile.txt", 1);
29        //print Dumper($this);
30        //parent::DesignPattern_Logger();
31      //return $this;      //return $this;
32    }    }
33    
34    function &_mkInstance($classname, $attributes = null) {    function &_mkInstance($classname, $attributes = null) {
35        parent::constructor();
36      $this->log( get_class($this) . "->_mkInstance( classname $classname )", LOG_DEBUG );      $this->log( get_class($this) . "->_mkInstance( classname $classname )", LOG_DEBUG );
37      if (isset($attributes)) {      if (isset($attributes)) {
38        $instance = new $classname($attributes);        $instance = new $classname($attributes);
39      } else {      } else {
40        $instance = new $classname;        $instance = new $classname;
41      }      }
42        //$this->log("ok", LOG_DEBUG);
43      return $instance;      return $instance;
44    }    }
45    
46    function _mkEmbeddedObjects($args) {    function _mkEmbeddedObjects($args) {
47    
48      $this->log( get_class($this) . "->_mkEmbeddedObjects()", LOG_DEBUG );      $this->log( get_parent_class($this) . "->_mkEmbeddedObjects( parent='" . $args[parent_name] . "' )", LOG_DEBUG );
49        //$this->log( get_parent_class($this) . "->_init_helpers: instantiating helper objects below '" . get_class($this) . "::'", LOG_DEBUG );
50    
51      foreach ($args[class_names] as $classname) {      foreach ($args[class_names] as $classname) {
52                
# Line 60  class DesignPattern_Bridge extends Desig Line 74  class DesignPattern_Bridge extends Desig
74        // helper gets reference to ourselves as a parent        // helper gets reference to ourselves as a parent
75        $this->$objectname->$args[parent_name] = &$this;        $this->$objectname->$args[parent_name] = &$this;
76        
77          $this->_call_initializer($objectname, 'constructor');
78        if ( $method = $args[run] ) {        if ( $method = $args[run] ) {
79          if (method_exists($this->$objectname, $method)) {          $this->_call_initializer($objectname, $method);
           $this->log( get_class($this) . "->_mkEmbeddedObjects: calling method \$this->" . $objectname . "->$method()", LOG_DEBUG );  
           $this->$objectname->$method();  
         }  
80        }        }
81            
82      }      }
83        
84    }    }
85    
86    function _init_logger() {    function _call_initializer($objectname, $method) {
87      // Log      if (method_exists($this->$objectname, $method)) {
88        // valid logging-levels are:        $this->log( get_class($this) . "->_call_initializer: autocalling \$this->" . $objectname . "->$method()", LOG_DEBUG );
89        // LOG_EMERG, LOG_ALERT, LOG_CRIT,        $this->$objectname->$method();
90        // LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG.      }
       // The default is LOG_INFO.  
       $logfile = 'log.txt';  
       $logfile = $this->config[path][base] . "core/var/log/logfile.txt";  
   
       // TODO: maybe include userid here?  
       //$log_ident = substr(session_id(), 10, 6);  
       $log_ident = session_id();  
       if ($this->config[mode][LOG]) {  
         $this->logger = &Log::singleton('file', $logfile, $log_ident);  
         //$site->logger = new Log_file($logfile, $log_ident);  
       } else {  
         $this->logger = &Log::singleton('dummy', $logfile, $log_ident);  
       }  
       $this->log( get_class($this) . "->_init_logger: ready\t\t--------------------", LOG_DEBUG );  
91    }    }
92    
93        
94  }  }
95  ?>  ?>

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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