fix config class bug.
This commit is contained in:
parent
c44b6264dd
commit
c81be6d27b
|
@ -60,14 +60,6 @@ public static function has($key)
|
|||
*/
|
||||
public static function get($key)
|
||||
{
|
||||
// First, we'll check the keyed cache of configuration items, as this will
|
||||
// be the fastest method of retrieving the configuration option. After an
|
||||
// item is retrieved, it is always stored in the cache by its key.
|
||||
if (array_key_exists($key, static::$cache))
|
||||
{
|
||||
return static::$cache[$key];
|
||||
}
|
||||
|
||||
list($bundle, $file, $item) = static::parse($key);
|
||||
|
||||
if ( ! static::load($bundle, $file)) return;
|
||||
|
@ -77,9 +69,14 @@ public static function get($key)
|
|||
// If a specific configuration item was not requested, the key will be null,
|
||||
// meaning we need to return the entire array of configuration item from the
|
||||
// requested configuration file. Otherwise we can return the item.
|
||||
$value = (is_null($item)) ? $items : array_get($items, $item);
|
||||
|
||||
return static::$cache[$key] = $value;
|
||||
if (is_null($item))
|
||||
{
|
||||
return $items;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array_get($items, $item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +99,22 @@ public static function get($key)
|
|||
*/
|
||||
public static function set($key, $value)
|
||||
{
|
||||
static::$cache[$key] = $value;
|
||||
list($bundle, $file, $item) = static::parse($key);
|
||||
|
||||
static::load($bundle, $file);
|
||||
|
||||
// If the item is null, it means the developer wishes to set the entire
|
||||
// configuration array to a given value, so we will pass the entire
|
||||
// array for the bundle into the array_set method, otherwise we'll
|
||||
// only pass the file array for the bundle.
|
||||
if (is_null($item))
|
||||
{
|
||||
array_set(static::$items[$bundle], $file, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_set(static::$items[$bundle][$file], $item, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,6 +127,14 @@ public static function set($key, $value)
|
|||
*/
|
||||
protected static function parse($key)
|
||||
{
|
||||
// First, we'll check the keyed cache of configuration items, as this will
|
||||
// be the fastest method of retrieving the configuration option. After an
|
||||
// item is parsed, it is always stored in the cache by its key.
|
||||
if (array_key_exists($key, static::$cache))
|
||||
{
|
||||
return static::$cache[$key];
|
||||
}
|
||||
|
||||
$bundle = Bundle::name($key);
|
||||
|
||||
$segments = explode('.', Bundle::element($key));
|
||||
|
@ -124,12 +144,14 @@ protected static function parse($key)
|
|||
// If that is the case, we'll make the item field of the array "null".
|
||||
if (count($segments) >= 2)
|
||||
{
|
||||
return array($bundle, $segments[0], implode('.', array_slice($segments, 1)));
|
||||
$parsed = array($bundle, $segments[0], implode('.', array_slice($segments, 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return array($bundle, $segments[0], null);
|
||||
$parsed = array($bundle, $segments[0], null);
|
||||
}
|
||||
|
||||
return static::$cache[$key] = $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue