/[cvs]/nfo/php/libs/org.netfrag.glib/Application/Core.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/Application/Core.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Mon Mar 3 21:11:01 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.3: +7 -2 lines
mungled the namespaces

1 joko 1.1 <?
2     // ---------------------------------------------------------------------------
3 joko 1.4 // $Id: Core.php,v 1.3 2003/02/09 17:05:15 joko Exp $
4 joko 1.1 // ---------------------------------------------------------------------------
5 joko 1.2 // $Log: Core.php,v $
6 joko 1.4 // Revision 1.3 2003/02/09 17:05:15 joko
7     // + minor update related to new log level constants
8     // + restructured get-/setter methods
9     //
10 joko 1.3 // Revision 1.2 2003/02/03 14:42:28 joko
11     // + added logging
12     // + methods for accessing configuration variables
13     //
14 joko 1.2 // Revision 1.1 2003/02/03 05:00:01 joko
15     // + initial commit
16     //
17 joko 1.1 // ---------------------------------------------------------------------------
18    
19    
20     /*
21    
22     ------------------------------------------------------------
23     How to use this?
24     ------------------------------------------------------------
25    
26     require_once("../etc/defaults.php");
27     require_once("../etc/includes.php");
28    
29     $init =
30     array(
31     'machine' => 'grasshopper',
32     'appname' => 'pub',
33     'resources' => array(
34     'machines' => '../etc/machines.php',
35     ),
36     'run' => array(
37     'boot' => array(
38     'scripts' => array( '../core/boot/boot.php' ),
39     //'objects' => array(),
40     'methods' => array( 'e_init', 'e_start', 'e_shutdown' ),
41     ),
42     ),
43     );
44    
45     $appConfig = mkObject('Application::Config', $init);
46    
47     $app = mkObject('Application::Core', $appConfig);
48     $app->run();
49    
50     ------------------------------------------------------------
51    
52     */
53    
54 joko 1.4 loadModule('Class::Logger');
55 joko 1.1
56 joko 1.4 class Application_Core extends Class_Logger {
57 joko 1.1
58     var $_config;
59    
60     function Application_Core($initCfgObject = null) {
61     $this->_config = $initCfgObject;
62     }
63    
64     function run() {
65     //print Dumper($this->_config);
66 joko 1.2
67     parent::constructor();
68    
69 joko 1.3 $this->log("-----------------------------------------------------------------", PEAR_LOG_INFO);
70     $this->log(get_class($this) . "->run: begin", PEAR_LOG_INFO);
71 joko 1.2
72     $cfg = $this->getConfig();
73    
74     //print Dumper($cfg); exit;
75    
76     if (!is_array($cfg[run])) { return; }
77    
78     foreach ($cfg[run] as $key => $container) {
79    
80     //print "key: $key<br>";
81 joko 1.1
82     // include files
83 joko 1.2 if (is_array($container[scripts])) {
84     foreach ($container[scripts] as $script) {
85     $this->_require_once_isolated($script);
86     $this->_config->merge();
87     }
88 joko 1.1 }
89    
90     // run procedural functions
91 joko 1.2 if (is_array($container[methods])) {
92     foreach ($container[methods] as $method) {
93 joko 1.3 $this->log(get_class($this) . "->run: calling function in global namespace: '$method'", PEAR_LOG_DEBUG);
94 joko 1.2 call_user_func($method);
95     }
96 joko 1.1 }
97 joko 1.2
98     }
99    
100 joko 1.3 $this->log(get_class($this) . "->run: end", PEAR_LOG_INFO);
101 joko 1.2
102     }
103    
104     function getConfig($var = null) {
105 joko 1.3 return $this->_config->get($var);
106 joko 1.2 }
107    
108     function _require_once_isolated($file) {
109 joko 1.3 $this->log(get_class($this) . "->_require_once_isolated: $file", PEAR_LOG_DEBUG);
110 joko 1.2 if (require_once($file)) {
111     return 1;
112 joko 1.1 }
113     }
114    
115 joko 1.2 function setConfigVar($var, $val) {
116     //print "$var=$val<br>";
117 joko 1.3 $this->_config->set_absolute($var, $val);
118 joko 1.2 }
119    
120     function getConfigVar($var) {
121 joko 1.3 return $this->_config->get_absolute($var);
122 joko 1.2 }
123    
124 joko 1.1 }
125    
126     ?>

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