--- nfo/php/libs/org.netfrag.glib/Application/Config.php 2003/02/03 04:59:29 1.2
+++ nfo/php/libs/org.netfrag.glib/Application/Config.php 2003/02/03 14:41:21 1.3
@@ -1,8 +1,12 @@
// ---------------------------------------------------------------------------
-// $Id: Config.php,v 1.2 2003/02/03 04:59:29 joko Exp $
+// $Id: Config.php,v 1.3 2003/02/03 14:41:21 joko Exp $
// ---------------------------------------------------------------------------
// $Log: Config.php,v $
+// Revision 1.3 2003/02/03 14:41:21 joko
+// + get- and set-methods to access configuration variables
+// + recursive merging mechanism
+//
// Revision 1.2 2003/02/03 04:59:29 joko
// + fixed: constructor can now get passed variable of *any type*
//
@@ -28,6 +32,7 @@
*/
+
class Application_Config {
var $_store;
@@ -37,6 +42,40 @@
//print "initCfg:
" . Dumper($initCfg) . "
";
$this->_store = $initCfg;
}
+
+ function merge() {
+ //$this->_store[run] = array_merge($this->_store['default'], $this->_store['init']);
+ foreach ($this->_store[_init][configkeys] as $configKey) {
+ //$this->_store[runtime] = array_merge($this->_store[runtime], $this->_store[$configKey]);
+ //$this->_store[runtime] = array_merge_recursive($this->_store[runtime], $this->_store[$configKey]);
+ $this->_store[runtime] = array_join_merge($this->_store[runtime], $this->_store[$configKey]);
+ }
+ //print Dumper($this);
+ }
+
+ function getPart($var = null) {
+ //$this->merge();
+ if ($var) {
+ return $this->getVar("runtime.$var");
+ } else {
+ return $this->getVar("runtime");
+ }
+ }
+
+ function setVar($var, $val) {
+ //$this->_store[runtime][$var] = $val;
+ //$deep = new Data_Deep($this->_store[runtime]);
+ $deep = new Data_Deep($this->_store);
+ $deep->set($var, $val);
+ }
+
+ function getVar($var) {
+ //$this->_store[runtime][$var] = $val;
+ //$deep = new Data_Deep($this->_store[runtime]);
+ $deep = new Data_Deep($this->_store);
+ return $deep->get($var);
+ }
+
}
?>
\ No newline at end of file