/[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.6 - (show annotations)
Mon Mar 10 22:58:48 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +5 -2 lines
+ fixed metadata for phpDocumentor

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

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