mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
改进驱动命名空间检测
This commit is contained in:
@@ -41,7 +41,7 @@ class Cache
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (true === $name || !isset(self::$instance[$name])) {
|
if (true === $name || !isset(self::$instance[$name])) {
|
||||||
$class = strpos($type, '\\') ? $type : '\\think\\cache\\driver\\' . ucwords($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\cache\\driver\\' . ucwords($type);
|
||||||
|
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
App::$debug && Log::record('[ CACHE ] INIT ' . $type . ':' . var_export($options, true), 'info');
|
App::$debug && Log::record('[ CACHE ] INIT ' . $type . ':' . var_export($options, true), 'info');
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class Db
|
|||||||
if (empty($options['type'])) {
|
if (empty($options['type'])) {
|
||||||
throw new \InvalidArgumentException('Underfined db type');
|
throw new \InvalidArgumentException('Underfined db type');
|
||||||
}
|
}
|
||||||
$class = strpos($options['type'], '\\') ? $options['type'] : '\\think\\db\\connector\\' . ucwords($options['type']);
|
$class = false !== strpos($options['type'], '\\') ? $options['type'] : '\\think\\db\\connector\\' . ucwords($options['type']);
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
App::$debug && Log::record('[ DB ] INIT ' . $options['type'] . ':' . var_export($options, true), 'info');
|
App::$debug && Log::record('[ DB ] INIT ' . $options['type'] . ':' . var_export($options, true), 'info');
|
||||||
if (true === $name) {
|
if (true === $name) {
|
||||||
|
|||||||
@@ -42,7 +42,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 = strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
|
||||||
self::$config = $config;
|
self::$config = $config;
|
||||||
unset($config['type']);
|
unset($config['type']);
|
||||||
self::$driver = new $class($config);
|
self::$driver = new $class($config);
|
||||||
@@ -57,7 +57,7 @@ class Log
|
|||||||
public static function alarm($config = [])
|
public static function alarm($config = [])
|
||||||
{
|
{
|
||||||
$type = isset($config['type']) ? $config['type'] : 'Email';
|
$type = isset($config['type']) ? $config['type'] : 'Email';
|
||||||
$class = strpos($type, '\\') ? $type : '\\think\\log\\alarm\\' . ucwords($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\alarm\\' . ucwords($type);
|
||||||
unset($config['type']);
|
unset($config['type']);
|
||||||
self::$alarm = new $class($config['alarm']);
|
self::$alarm = new $class($config['alarm']);
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
use think\Hook;
|
use think\Hook;
|
||||||
use think\Request;
|
|
||||||
|
|
||||||
class Response
|
class Response
|
||||||
{
|
{
|
||||||
@@ -77,7 +76,7 @@ class Response
|
|||||||
$type = empty($type) ? 'null' : strtolower($type);
|
$type = empty($type) ? 'null' : strtolower($type);
|
||||||
|
|
||||||
if (!isset(self::$instance[$type])) {
|
if (!isset(self::$instance[$type])) {
|
||||||
$class = strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst($type);
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
$response = new $class($data, $type, $options);
|
$response = new $class($data, $type, $options);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Session
|
|||||||
}
|
}
|
||||||
if (!empty($config['type'])) {
|
if (!empty($config['type'])) {
|
||||||
// 读取session驱动
|
// 读取session驱动
|
||||||
$class = strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']);
|
$class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']);
|
||||||
|
|
||||||
// 检查驱动类
|
// 检查驱动类
|
||||||
if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
|
if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Template
|
|||||||
|
|
||||||
// 初始化模板编译存储器
|
// 初始化模板编译存储器
|
||||||
$type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File';
|
$type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File';
|
||||||
$class = strpos($type, '\\') ? $type : '\\think\\template\\driver\\' . ucwords($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\template\\driver\\' . ucwords($type);
|
||||||
$this->storage = new $class();
|
$this->storage = new $class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class View
|
|||||||
$type = !empty($options['type']) ? $options['type'] : 'Think';
|
$type = !empty($options['type']) ? $options['type'] : 'Think';
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = strpos($type, '\\') ? $type : '\\think\\view\\driver\\' . ucfirst($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\view\\driver\\' . ucfirst($type);
|
||||||
if (isset($options['type'])) {
|
if (isset($options['type'])) {
|
||||||
unset($options['type']);
|
unset($options['type']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ use think\Config;
|
|||||||
use think\Db;
|
use think\Db;
|
||||||
use think\db\Builder;
|
use think\db\Builder;
|
||||||
use think\db\Connection;
|
use think\db\Connection;
|
||||||
|
use think\db\exception\BindParamException;
|
||||||
|
use think\db\exception\DataNotFoundException;
|
||||||
|
use think\db\exception\ModelNotFoundException;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
use think\exception\DbException;
|
use think\exception\DbException;
|
||||||
use think\exception\PDOException;
|
use think\exception\PDOException;
|
||||||
use think\db\exception\BindParamException;
|
|
||||||
use think\db\exception\ModelNotFoundException;
|
|
||||||
use think\db\exception\DataNotFoundException;
|
|
||||||
use think\Loader;
|
use think\Loader;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use think\model\Relation;
|
use think\model\Relation;
|
||||||
@@ -962,7 +962,7 @@ class Query
|
|||||||
{
|
{
|
||||||
$config = array_merge(Config::get('paginate'), $config);
|
$config = array_merge(Config::get('paginate'), $config);
|
||||||
$listRows = $listRows ?: $config['list_rows'];
|
$listRows = $listRows ?: $config['list_rows'];
|
||||||
$class = strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']);
|
$class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']);
|
||||||
$page = isset($config['page']) ? (int) $config['page'] : call_user_func([
|
$page = isset($config['page']) ? (int) $config['page'] : call_user_func([
|
||||||
$class,
|
$class,
|
||||||
'getCurrentPage',
|
'getCurrentPage',
|
||||||
|
|||||||
Reference in New Issue
Block a user