mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Hook类 改进Model类时间戳写入
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
@@ -69,7 +68,8 @@ class Hook
|
|||||||
*/
|
*/
|
||||||
public static function get($tag = '')
|
public static function get($tag = '')
|
||||||
{
|
{
|
||||||
if (empty($tag)) {//获取全部的插件信息
|
if (empty($tag)) {
|
||||||
|
//获取全部的插件信息
|
||||||
return self::$tags;
|
return self::$tags;
|
||||||
} else {
|
} else {
|
||||||
return array_key_exists($tag, self::$tags) ? self::$tags[$tag] : [];
|
return array_key_exists($tag, self::$tags) ? self::$tags[$tag] : [];
|
||||||
@@ -90,7 +90,8 @@ class Hook
|
|||||||
$tags = static::get($tag);
|
$tags = static::get($tag);
|
||||||
foreach ($tags as $key => $name) {
|
foreach ($tags as $key => $name) {
|
||||||
$results[$key] = self::exec($name, $tag, $params, $extra);
|
$results[$key] = self::exec($name, $tag, $params, $extra);
|
||||||
if (false === $results[$key]) {// 如果返回false 则中断行为执行
|
if (false === $results[$key]) {
|
||||||
|
// 如果返回false 则中断行为执行
|
||||||
break;
|
break;
|
||||||
} elseif (!is_null($results[$key]) && $once) {
|
} elseif (!is_null($results[$key]) && $once) {
|
||||||
break;
|
break;
|
||||||
@@ -114,11 +115,12 @@ class Hook
|
|||||||
$result = call_user_func_array($class, [ & $params, $extra]);
|
$result = call_user_func_array($class, [ & $params, $extra]);
|
||||||
$class = 'Closure';
|
$class = 'Closure';
|
||||||
} elseif (is_object($class)) {
|
} elseif (is_object($class)) {
|
||||||
$result = call_user_func_array([$class, $tag], [ & $params, $extra]);
|
$result = $class->$tag($params, $extra);
|
||||||
$class = get_class($class);
|
$class = get_class($class);
|
||||||
} else {
|
} else {
|
||||||
$obj = new $class();
|
$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) {
|
if (App::$debug) {
|
||||||
Debug::remark('behavior_end', 'time');
|
Debug::remark('behavior_end', 'time');
|
||||||
|
|||||||
@@ -326,7 +326,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
$value = date($format, $_SERVER['REQUEST_TIME']);
|
$value = date($format, $_SERVER['REQUEST_TIME']);
|
||||||
break;
|
break;
|
||||||
case 'timestamp':
|
case 'timestamp':
|
||||||
case 'int':
|
case 'integer':
|
||||||
|
default:
|
||||||
$value = $_SERVER['REQUEST_TIME'];
|
$value = $_SERVER['REQUEST_TIME'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user