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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Sun Feb 9 17:05:15 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.2: +13 -8 lines
+ minor update related to new log level constants
+ restructured get-/setter methods

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

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