overall code refactoring.

This commit is contained in:
Taylor Otwell
2011-06-14 17:27:11 -05:00
parent af24e8db45
commit 30c83f265d
36 changed files with 720 additions and 559 deletions

View File

@@ -17,8 +17,14 @@ class Config {
*/
public static function get($key)
{
// -----------------------------------------------------
// Parse the key to separate the file and key name.
// -----------------------------------------------------
list($file, $key) = static::parse($key);
// -----------------------------------------------------
// Load the appropriate configuration file.
// -----------------------------------------------------
static::load($file);
return (array_key_exists($key, static::$items[$file])) ? static::$items[$file][$key] : null;
@@ -33,8 +39,14 @@ class Config {
*/
public static function set($key, $value)
{
// -----------------------------------------------------
// Parse the key to separate the file and key name.
// -----------------------------------------------------
list($file, $key) = static::parse($key);
// -----------------------------------------------------
// Load the appropriate configuration file.
// -----------------------------------------------------
static::load($file);
static::$items[$file][$key] = $value;
@@ -55,6 +67,11 @@ class Config {
throw new \Exception("Invalid configuration key [$key].");
}
// -----------------------------------------------------
// The left side of the dot is the file name, while
// the right side of the dot is the item within that
// file being requested.
// -----------------------------------------------------
return array($segments[0], implode('.', array_slice($segments, 1)));
}
@@ -66,6 +83,9 @@ class Config {
*/
public static function load($file)
{
// -----------------------------------------------------
// If we have already loaded the file, bail out.
// -----------------------------------------------------
if (array_key_exists($file, static::$items))
{
return;