mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
改进实例化类 命名空间大小写的问题
This commit is contained in:
@@ -29,7 +29,7 @@ class Cache
|
|||||||
public static function connect($options = [])
|
public static function connect($options = [])
|
||||||
{
|
{
|
||||||
$type = !empty($options['type']) ? $options['type'] : 'File';
|
$type = !empty($options['type']) ? $options['type'] : 'File';
|
||||||
$class = 'think\\cache\\driver\\' . strtolower($type);
|
$class = 'think\\cache\\driver\\' . ucwords($type);
|
||||||
self::$handler = new $class($options);
|
self::$handler = new $class($options);
|
||||||
return self::$handler;
|
return self::$handler;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Loader
|
|||||||
include self::$map[$class];
|
include self::$map[$class];
|
||||||
} else {
|
} else {
|
||||||
// 命名空间自动加载
|
// 命名空间自动加载
|
||||||
$name = strstr($class, '\\', true);
|
$name = strtolower(strstr($class, '\\', true));
|
||||||
if (isset(self::$namespace[$name])) {
|
if (isset(self::$namespace[$name])) {
|
||||||
// 注册的命名空间
|
// 注册的命名空间
|
||||||
$path = dirname(self::$namespace[$name]) . '/';
|
$path = dirname(self::$namespace[$name]) . '/';
|
||||||
@@ -246,7 +246,7 @@ class Loader
|
|||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
$o = new $class();
|
$o = new $class();
|
||||||
if (!empty($method) && method_exists($o, $method)) {
|
if (!empty($method) && method_exists($o, $method)) {
|
||||||
$_instance[$identify] = call_user_func_array([ & $o, $method],[]);
|
$_instance[$identify] = call_user_func_array([ & $o, $method], []);
|
||||||
} else {
|
} else {
|
||||||
$_instance[$identify] = $o;
|
$_instance[$identify] = $o;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class Log
|
|||||||
public static function init($config = [])
|
public static function init($config = [])
|
||||||
{
|
{
|
||||||
$type = isset($config['type']) ? $config['type'] : 'File';
|
$type = isset($config['type']) ? $config['type'] : 'File';
|
||||||
$class = '\\think\\log\\driver\\' . strtolower($type);
|
$class = '\\think\\log\\driver\\' . ucwords($type);
|
||||||
unset($config['type']);
|
unset($config['type']);
|
||||||
self::$storage = new $class($config);
|
self::$storage = new $class($config);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class Template
|
|||||||
|
|
||||||
// 初始化模板编译存储器
|
// 初始化模板编译存储器
|
||||||
$type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File';
|
$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();
|
$this->storage = new $class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class View
|
|||||||
* @param string $value 值
|
* @param string $value 值
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function config($config = '',$value='')
|
public function config($config = '', $value = '')
|
||||||
{
|
{
|
||||||
if (is_array($config)) {
|
if (is_array($config)) {
|
||||||
foreach ($this->config as $key => $val) {
|
foreach ($this->config as $key => $val) {
|
||||||
@@ -70,7 +70,7 @@ class View
|
|||||||
$this->config[$key] = $config[$key];
|
$this->config[$key] = $config[$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$this->config[$config] = $value;
|
$this->config[$config] = $value;
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
@@ -85,7 +85,7 @@ class View
|
|||||||
*/
|
*/
|
||||||
public function engine($engine, array $config = [])
|
public function engine($engine, array $config = [])
|
||||||
{
|
{
|
||||||
$class = '\\think\\view\\driver\\' . strtolower($engine);
|
$class = '\\think\\view\\driver\\' . ucwords($engine);
|
||||||
$this->engine = new $class($config);
|
$this->engine = new $class($config);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ return [
|
|||||||
'think\Log' => CORE_PATH . 'log' . EXT,
|
'think\Log' => CORE_PATH . 'log' . EXT,
|
||||||
'think\log\driver\File' => CORE_PATH . 'log' . DS . 'driver' . DS . 'file' . EXT,
|
'think\log\driver\File' => CORE_PATH . 'log' . DS . 'driver' . DS . 'file' . EXT,
|
||||||
'think\Config' => CORE_PATH . 'config' . EXT,
|
'think\Config' => CORE_PATH . 'config' . EXT,
|
||||||
|
'think\Create' => CORE_PATH . 'create' . EXT,
|
||||||
'think\Route' => CORE_PATH . 'route' . EXT,
|
'think\Route' => CORE_PATH . 'route' . EXT,
|
||||||
'think\Exception' => CORE_PATH . 'exception' . EXT,
|
'think\Exception' => CORE_PATH . 'exception' . EXT,
|
||||||
'think\Model' => CORE_PATH . 'model' . EXT,
|
'think\Model' => CORE_PATH . 'model' . EXT,
|
||||||
'think\Db' => CORE_PATH . 'db' . EXT,
|
'think\Db' => CORE_PATH . 'db' . EXT,
|
||||||
'think\Db\Driver' => CORE_PATH . 'db'.DS.'driver' . EXT,
|
'think\Db\Driver' => CORE_PATH . 'db' . DS . 'driver' . EXT,
|
||||||
'think\Template' => CORE_PATH . 'template' . EXT,
|
'think\Template' => CORE_PATH . 'template' . EXT,
|
||||||
'think\view\driver\Think' => CORE_PATH . 'view' . DS . 'driver' . DS . 'think' . EXT,
|
'think\view\driver\Think' => CORE_PATH . 'view' . DS . 'driver' . DS . 'think' . EXT,
|
||||||
'think\template\driver\File' => CORE_PATH . 'template' . DS . 'driver' . DS . 'file' . EXT,
|
'think\template\driver\File' => CORE_PATH . 'template' . DS . 'driver' . DS . 'file' . EXT,
|
||||||
@@ -42,7 +43,7 @@ return [
|
|||||||
'think\Url' => CORE_PATH . 'url' . EXT,
|
'think\Url' => CORE_PATH . 'url' . EXT,
|
||||||
'think\Debug' => CORE_PATH . 'debug' . EXT,
|
'think\Debug' => CORE_PATH . 'debug' . EXT,
|
||||||
'think\Input' => CORE_PATH . 'input' . EXT,
|
'think\Input' => CORE_PATH . 'input' . EXT,
|
||||||
'think\Lang' => CORE_PATH . 'lang' . EXT
|
'think\Lang' => CORE_PATH . 'lang' . EXT,
|
||||||
],
|
],
|
||||||
|
|
||||||
'init' => [],
|
'init' => [],
|
||||||
|
|||||||
Reference in New Issue
Block a user