-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathConfig.php
80 lines (54 loc) · 1.63 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
class Wave_Config {
private static $_writable = false;
private static $_readable = true;
private $_data = false;
public function __construct($config){
$config_data = include ($config);
$this->_data = $this->loadFromArray($config_data);
}
public static function loadFromArray($array) {
$return = new Wave_Config_Row();
foreach ($array as $k => $v) {
if (is_array($v)) {
$return->$k = Wave_Config::loadFromArray($v);
} else {
$return->$k = $v;
}
}
return $return;
}
public function __get($offset){
return $this->_data->{$offset};
}
public static function get($file){
static $configs;
if (!isset($configs[$file])){
//no special config - try to load file.
$file_path = APP_ROOT . "config/$file.php";
if(!file_exists($file_path))
return null;
$configs[$file] = new Wave_Config($file_path);
}
return $configs[$file];
}
public static function buildRoutes($controllers){
trigger_error('Wave_Router::buildRoutes() is depreciated. Use Wave_Router_Generator::buildRoutes() instead', E_USER_DEPRECATED);
return Wave_Router_Generator::buildRoutes($controllers);
}
}
class Wave_Config_Row implements ArrayAccess {
public function offsetSet($offset, $value) {
$this->{$offset} = $value;
}
public function offsetExists($offset) {
return isset($this->{$offset});
}
public function offsetUnset($offset) {
unset($this->{$offset});
}
public function offsetGet($offset) {
return isset($this->{$offset}) ? $this->{$offset} : null;
}
}
?>