Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
ThinkPHP升级为 ThinkPHP 5.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
yuan1994 committed Dec 20, 2016
1 parent dcbacf7 commit 41870eb
Show file tree
Hide file tree
Showing 48 changed files with 1,314 additions and 1,318 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ https://github.com/yuan1994/tpadmin/archive/master.zip

## 鸣谢:
本平台使用了如下框架或插件、源码
* ThinkPHP 5.0.3 正式版
* ThinkPHP 5.0.4 正式版
* Hui.admin v2.5
* layer
* jQuery Validform
Expand Down
4 changes: 2 additions & 2 deletions application/admin/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

return [
'module_init' => [
'\\app\\common\behavior\\WebLog',
'\\app\\common\\behavior\\WebLog',
],
'app_end' => [
'\\app\\common\behavior\\WebLog',
'\\app\\common\\behavior\\WebLog',
]
];
20 changes: 20 additions & 0 deletions application/common/behavior/WebLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ public function module_init(&$param)
$this->init();
}

/**
* module_init同名函数,ThinkPHP5.0.4默默的将行为规范为psr-4标准
*
* @param $param
*/
public function moduleInit(&$param)
{
$this->init();
}

/**
* 应用执行完
*
Expand All @@ -110,6 +120,16 @@ public function app_end(&$param)
$this->record();
}

/**
* app_end同名函数,ThinkPHP5.0.4默默的将行为规范为psr-4标准
*
* @param $param
*/
public function appEnd(&$param)
{
$this->record();
}

/**
* 设置配置信息
*
Expand Down
40 changes: 20 additions & 20 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion thinkphp/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------

define('THINK_VERSION', '5.0.3');
define('THINK_VERSION', '5.0.4');
define('THINK_START_TIME', microtime(true));
define('THINK_START_MEM', memory_get_usage());
define('EXT', '.php');
Expand Down
4 changes: 3 additions & 1 deletion thinkphp/convention.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@
'template' => [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Think',
// 模板路径
// 视图基础目录,配置目录为所有模块的视图起始目录
'view_base' => '',
// 当前模板的视图目录 留空为自动获取
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
Expand Down
2 changes: 1 addition & 1 deletion thinkphp/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function input($key = '', $default = null, $filter = '')
}
if ($pos = strpos($key, '.')) {
// 指定参数来源
list($method, $key) = explode('.', $key);
list($method, $key) = explode('.', $key, 2);
if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) {
$key = $method . '.' . $key;
$method = 'param';
Expand Down
1 change: 1 addition & 0 deletions thinkphp/lang/zh-cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@
'sae mc write error' => 'SAE mc 写入错误',
'route name not exists' => '路由标识不存在(或参数不够)',
'invalid request' => '非法请求',
'bind attr has exists' => '模型的属性已经存在',
];
16 changes: 10 additions & 6 deletions thinkphp/library/think/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,13 @@ public static function run(Request $request = null)
break;
case 'controller':
// 执行控制器操作
$data = Loader::action($dispatch['controller']);
$vars = Request::instance()->param();
$data = Loader::action($dispatch['controller'], array_merge($vars, $dispatch['var']));
break;
case 'method':
// 执行回调方法
$data = self::invokeMethod($dispatch['method']);
$vars = Request::instance()->param();
$data = self::invokeMethod($dispatch['method'], array_merge($vars, $dispatch['var']));
break;
case 'function':
// 执行闭包
Expand Down Expand Up @@ -220,7 +222,7 @@ public static function invokeFunction($function, $vars = [])
public static function invokeMethod($method, $vars = [])
{
if (is_array($method)) {
$class = is_object($method[0]) ? $method[0] : new $method[0](Request::instance());
$class = is_object($method[0]) ? $method[0] : self::invokeClass($method[0]);
$reflect = new \ReflectionMethod($class, $method[1]);
} else {
// 静态方法
Expand Down Expand Up @@ -345,6 +347,8 @@ public static function module($result, $config, $convert = null)
// 初始化模块
$request->module($module);
$config = self::init($module);
// 模块请求缓存检查
$request->cache($config['request_cache'], $config['request_cache_expire']);
} else {
throw new HttpException(404, 'module not exists:' . $module);
}
Expand Down Expand Up @@ -386,7 +390,7 @@ public static function module($result, $config, $convert = null)
} elseif (is_callable([$instance, '_empty'])) {
// 空操作
$call = [$instance, '_empty'];
$vars = [$action];
$vars = [$actionName];
} else {
// 操作不存在
throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()');
Expand Down Expand Up @@ -446,9 +450,9 @@ public static function initCommon()
// 监听app_init
Hook::listen('app_init');

self::$init = $config;
self::$init = true;
}
return self::$init;
return Config::get();
}

/**
Expand Down
29 changes: 29 additions & 0 deletions thinkphp/library/think/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,35 @@ public static function clear($tag = null)
return self::$handler->clear($tag);
}

/**
* 读取缓存并删除
* @access public
* @param string $name 缓存变量名
* @return mixed
*/
public static function pull($name)
{
self::init();
self::$readTimes++;
self::$writeTimes++;
return self::$handler->pull($name);
}

/**
* 如果不存在则写入缓存
* @access public
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param int $expire 有效时间 0为永久
* @return mixed
*/
public static function remember($name, $value, $expire = null)
{
self::init();
self::$readTimes++;
return self::$handler->remember($name, $value, $expire);
}

/**
* 缓存标签
* @access public
Expand Down
8 changes: 6 additions & 2 deletions thinkphp/library/think/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ class Controller
{
use \traits\controller\Jump;

// 视图类实例
/**
* @var \think\View 视图类实例
*/
protected $view;
// Request实例
/**
* @var \think\Request Request实例
*/
protected $request;
// 验证失败是否抛出异常
protected $failException = false;
Expand Down
16 changes: 16 additions & 0 deletions thinkphp/library/think/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ public static function set($name, $value = '', $option = null)
$_COOKIE[$name] = $value;
}

/**
* 永久保存Cookie数据
* @param string $name cookie名称
* @param mixed $value cookie
* @param mixed $option 可选参数 可能会是 null|integer|string
* @return void
*/
public static function forever($name, $value = '', $option = null)
{
if (is_null($option) || is_numeric($option)) {
$option = [];
}
$option['expire'] = 315360000;
self::set($name, $value, $option);
}

/**
* 判断Cookie数据
* @param string $name cookie名称
Expand Down
Loading

0 comments on commit 41870eb

Please sign in to comment.