This commit is contained in:
luofei614
2015-12-09 23:36:52 -05:00
8 changed files with 89 additions and 36 deletions

View File

@@ -29,7 +29,7 @@ class Cache
public static function connect($options = [])
{
$type = !empty($options['type']) ? $options['type'] : 'File';
$class = 'think\\cache\\driver\\' . strtolower($type);
$class = 'think\\cache\\driver\\' . ucwords($type);
self::$handler = new $class($options);
return self::$handler;
}

View File

@@ -33,6 +33,7 @@ class Config
if (empty($type)) {
$type = substr(strrchr($config, '.'), 1);
}
$range = $range ? $range : self::$range;
$class = '\\think\\config\\driver\\' . strtolower($type);
self::set((new $class())->parse($config), '', $range);
}
@@ -40,7 +41,8 @@ class Config
// 加载配置文件
public static function load($file, $name = '', $range = '')
{
$file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
$range = $range ? $range : self::$range;
$file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
if (!isset(self::$config[$range])) {
self::$config[$range] = [];
}

View File

@@ -26,7 +26,7 @@ class Loader
include self::$map[$class];
} else {
// 命名空间自动加载
$name = strstr($class, '\\', true);
$name = strtolower(strstr($class, '\\', true));
if (isset(self::$namespace[$name])) {
// 注册的命名空间
$path = dirname(self::$namespace[$name]) . '/';
@@ -246,7 +246,7 @@ class Loader
if (class_exists($class)) {
$o = new $class();
if (!empty($method) && method_exists($o, $method)) {
$_instance[$identify] = call_user_func_array([ & $o, $method],[]);
$_instance[$identify] = call_user_func_array([ & $o, $method], []);
} else {
$_instance[$identify] = $o;
}

View File

@@ -22,7 +22,7 @@ class Log
public static function init($config = [])
{
$type = isset($config['type']) ? $config['type'] : 'File';
$class = '\\think\\log\\driver\\' . strtolower($type);
$class = '\\think\\log\\driver\\' . ucwords($type);
unset($config['type']);
self::$storage = new $class($config);
}

View File

@@ -19,9 +19,9 @@ namespace think;
class Template
{
// 模板变量
protected $data = [];
protected $data = [];
// 引擎配置
protected $config = [
protected $config = [
'tpl_path' => VIEW_PATH, // 模板路径
'tpl_suffix' => '.html', // 默认模板文件后缀
'cache_suffix' => '.php', // 默认模板缓存后缀
@@ -63,7 +63,7 @@ class Template
// 初始化模板编译存储器
$type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File';
$class = '\\think\\template\\driver\\' . strtolower($type);
$class = '\\think\\template\\driver\\' . ucwords($type);
$this->storage = new $class();
}
@@ -658,10 +658,10 @@ class Template
//模板函数过滤
$fun = strtolower(trim($args[0]));
switch ($fun) {
case 'default': // 特殊模板函数
case 'default': // 特殊模板函数
$name = '(' . $name . ')?(' . $name . '):' . $args[1];
break;
default: // 通用模板函数
default: // 通用模板函数
if (!in_array($fun, $template_deny_funs)) {
if (isset($args[1])) {
if (strstr($args[1], '###')) {

View File

@@ -62,7 +62,7 @@ class View
* @param string $value 值
* @return View
*/
public function config($config = '',$value='')
public function config($config = '', $value = '')
{
if (is_array($config)) {
foreach ($this->config as $key => $val) {
@@ -70,8 +70,8 @@ class View
$this->config[$key] = $config[$key];
}
}
}else{
$this->config[$config] = $value;
} else {
$this->config[$config] = $value;
}
return $this;
}
@@ -85,7 +85,7 @@ class View
*/
public function engine($engine, array $config = [])
{
$class = '\\think\\view\\driver\\' . strtolower($engine);
$class = '\\think\\view\\driver\\' . ucwords($engine);
$this->engine = new $class($config);
return $this;
}