-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.php
50 lines (42 loc) · 1.1 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
<?php
namespace Panada\Resource;
use Panada\Resource\Loader;
/**
* Handler for configuration.
*
* @package Resource
* @link http://panadaframework.com/
* @license http://www.opensource.org/licenses/bsd-license.php
* @author Iskandar Soesman <k4ndar@yahoo.com>
* @since Version 1.0.0
*/
class Config
{
private static $config = [];
private static function _cache($name)
{
$app = Gear::$appDir;
if (!isset(self::$config[$name])) {
$array = require $app . 'config/' . $name . '.php';
self::$config[$name] = $array;
return $array;
}
return self::$config[$name];
}
/**
* Handler for user defined config
*/
public static function __callStatic($name, $arguments = [])
{
// Does cache for this config exists?
if (isset(self::$config[$name])) {
return self::$config[$name];
}
// Does the config file exists?
try {
return self::_cache($name);
} catch (\Exception $e) {
throw $e;
}
}
}