mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 08:02:48 +08:00
Merge branch 'master' of https://github.com/top-think/framework
This commit is contained in:
@@ -41,7 +41,7 @@ class Cache
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
namespace think;
|
||||
|
||||
use think\App;
|
||||
|
||||
class Config
|
||||
{
|
||||
// 配置参数
|
||||
@@ -42,7 +40,7 @@ class Config
|
||||
if (empty($type)) {
|
||||
$type = pathinfo($config, PATHINFO_EXTENSION);
|
||||
}
|
||||
$class = strpos($type, '\\') ? $type : '\\think\\config\\driver\\' . ucwords($type);
|
||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\config\\driver\\' . ucwords($type);
|
||||
self::set((new $class())->parse($config), $name, $range);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class Db
|
||||
if (empty($options['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');
|
||||
if (true === $name) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class Log
|
||||
public static function init($config = [])
|
||||
{
|
||||
$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;
|
||||
unset($config['type']);
|
||||
self::$driver = new $class($config);
|
||||
@@ -57,7 +57,7 @@ class Log
|
||||
public static function alarm($config = [])
|
||||
{
|
||||
$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']);
|
||||
self::$alarm = new $class($config['alarm']);
|
||||
// 记录初始化信息
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace think;
|
||||
|
||||
use think\Hook;
|
||||
use think\Request;
|
||||
|
||||
class Response
|
||||
{
|
||||
@@ -77,7 +76,7 @@ class Response
|
||||
$type = empty($type) ? 'null' : strtolower($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)) {
|
||||
$response = new $class($data, $type, $options);
|
||||
} else {
|
||||
|
||||
@@ -89,7 +89,7 @@ class Session
|
||||
}
|
||||
if (!empty($config['type'])) {
|
||||
// 读取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))) {
|
||||
|
||||
@@ -70,7 +70,7 @@ class Template
|
||||
|
||||
// 初始化模板编译存储器
|
||||
$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();
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ class Url
|
||||
// 添加参数
|
||||
if (Config::get('url_common_param')) {
|
||||
$vars = urldecode(http_build_query($vars));
|
||||
$url .= $suffix . $anchor . '?' . $vars;
|
||||
$url .= $suffix . '?' . $vars . $anchor;
|
||||
} else {
|
||||
foreach ($vars as $var => $val) {
|
||||
if ('' !== trim($val)) {
|
||||
|
||||
@@ -83,7 +83,7 @@ class View
|
||||
$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'])) {
|
||||
unset($options['type']);
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ use think\Config;
|
||||
use think\Db;
|
||||
use think\db\Builder;
|
||||
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\DbException;
|
||||
use think\exception\PDOException;
|
||||
use think\db\exception\BindParamException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\Loader;
|
||||
use think\Model;
|
||||
use think\model\Relation;
|
||||
@@ -962,7 +962,7 @@ class Query
|
||||
{
|
||||
$config = array_merge(Config::get('paginate'), $config);
|
||||
$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([
|
||||
$class,
|
||||
'getCurrentPage',
|
||||
|
||||
@@ -72,5 +72,8 @@ class urlTest extends \PHPUnit_Framework_TestCase
|
||||
Route::get('blog/:id', 'index/blog');
|
||||
Config::set('url_html_suffix', 'shtml');
|
||||
$this->assertEquals('/blog/10.shtml#detail', Url::build('/blog/10#detail'));
|
||||
|
||||
Config::set('url_common_param', true);
|
||||
$this->assertEquals('/blog/10.shtml?foo=bar#detail', Url::build('/blog/10#detail', "foo=bar"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user