改进Hook类 改进Model类时间戳写入

This commit is contained in:
thinkphp
2016-12-18 08:21:35 +08:00
parent 0fe0edb80e
commit e2ab86b962
2 changed files with 107 additions and 104 deletions

View File

@@ -1,5 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
@@ -69,7 +68,8 @@ class Hook
*/
public static function get($tag = '')
{
if (empty($tag)) {//获取全部的插件信息
if (empty($tag)) {
//获取全部的插件信息
return self::$tags;
} else {
return array_key_exists($tag, self::$tags) ? self::$tags[$tag] : [];
@@ -90,7 +90,8 @@ class Hook
$tags = static::get($tag);
foreach ($tags as $key => $name) {
$results[$key] = self::exec($name, $tag, $params, $extra);
if (false === $results[$key]) {// 如果返回false 则中断行为执行
if (false === $results[$key]) {
// 如果返回false 则中断行为执行
break;
} elseif (!is_null($results[$key]) && $once) {
break;
@@ -114,11 +115,12 @@ class Hook
$result = call_user_func_array($class, [ & $params, $extra]);
$class = 'Closure';
} elseif (is_object($class)) {
$result = call_user_func_array([$class, $tag], [ & $params, $extra]);
$result = $class->$tag($params, $extra);
$class = get_class($class);
} else {
$obj = new $class();
$result = ($tag && is_callable([$obj, $tag])) ? $obj->$tag($params, $extra) : $obj->run($params, $extra);
$method = ($tag && is_callable([$obj, $tag])) ? $tag : 'run';
$result = $obj->$method($params, $extra);
}
if (App::$debug) {
Debug::remark('behavior_end', 'time');

View File

@@ -326,7 +326,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$value = date($format, $_SERVER['REQUEST_TIME']);
break;
case 'timestamp':
case 'int':
case 'integer':
default:
$value = $_SERVER['REQUEST_TIME'];
break;
}