改名
This commit is contained in:
@@ -20,7 +20,7 @@ use Snowflake\Abstracts\Component;
|
|||||||
class Config extends Component
|
class Config extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
const ERROR_MESSAGE = 'The not find :key in app configs.';
|
const ERROR_MESSAGE = 'The not find %s in app configs.';
|
||||||
|
|
||||||
public $data;
|
public $data;
|
||||||
|
|
||||||
@@ -43,21 +43,20 @@ class Config extends Component
|
|||||||
public static function get($key, $try = FALSE, $default = null)
|
public static function get($key, $try = FALSE, $default = null)
|
||||||
{
|
{
|
||||||
$explode = explode('.', $key);
|
$explode = explode('.', $key);
|
||||||
|
|
||||||
$instance = Snowflake::app()->getConfig()->getData();
|
$instance = Snowflake::app()->getConfig()->getData();
|
||||||
foreach ($explode as $index => $value) {
|
foreach ($explode as $index => $value) {
|
||||||
|
if (empty($value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!isset($instance[$value]) && $try) {
|
if (!isset($instance[$value]) && $try) {
|
||||||
throw new ConfigException(str_replace(':key', $key, self::ERROR_MESSAGE));
|
throw new ConfigException(sprintf(self::ERROR_MESSAGE, $value));
|
||||||
}
|
}
|
||||||
$instance = $instance[$value];
|
$instance = $instance[$value];
|
||||||
if (!is_array($instance) && $index + 1 < count($explode)) {
|
if (!is_array($instance) && $index + 1 < count($explode)) {
|
||||||
throw new ConfigException(str_replace(':key', $key, self::ERROR_MESSAGE));
|
throw new ConfigException(sprintf(self::ERROR_MESSAGE, $value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($instance)) {
|
return empty($instance) ? $default : $instance;
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user