-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathsfConfig.class.php
88 lines (80 loc) · 2.29 KB
/
sfConfig.class.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
81
82
83
84
85
86
87
88
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* sfConfig stores all configuration information for a symfony application.
*
* @author Fabien Potencier <[email protected]>
*/
class sfConfig
{
protected static $config = [];
/**
* Retrieves a config parameter.
*
* @param string $name A config parameter name
* @param mixed $default A default config parameter value
*
* @return mixed A config parameter value, if the config parameter exists, otherwise null
*/
public static function get($name, $default = null)
{
return self::$config[$name] ?? $default;
}
/**
* Indicates whether or not a config parameter exists.
*
* @param string $name A config parameter name
*
* @return bool true, if the config parameter exists, otherwise false
*/
public static function has($name)
{
return array_key_exists($name, self::$config);
}
/**
* Sets a config parameter.
*
* If a config parameter with the name already exists the value will be overridden.
*
* @param string $name A config parameter name
* @param mixed $value A config parameter value
*/
public static function set($name, $value)
{
self::$config[$name] = $value;
}
/**
* Sets an array of config parameters.
*
* If an existing config parameter name matches any of the keys in the supplied
* array, the associated value will be overridden.
*
* @param array $parameters An associative array of config parameters and their associated values
*/
public static function add($parameters = [])
{
self::$config = array_merge(self::$config, $parameters);
}
/**
* Retrieves all configuration parameters.
*
* @return array an associative array of configuration parameters
*/
public static function getAll()
{
return self::$config;
}
/**
* Clears all current config parameters.
*/
public static function clear()
{
self::$config = [];
}
}