diff --git a/library/think/Loader.php b/library/think/Loader.php index 82a890af..beb4b4f8 100644 --- a/library/think/Loader.php +++ b/library/think/Loader.php @@ -337,9 +337,6 @@ class Loader $module = APP_MULTI_MODULE ? MODULE_NAME : ''; } $class = self::parseClass($module, $layer, $name); - // controller_load - APP_HOOK && Hook::listen('controller_load', $class); - if (class_exists($class)) { $action = new $class; $_instance[$name . $layer] = $action; diff --git a/library/think/Validate.php b/library/think/Validate.php index cc7e5576..9fc5c1f1 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -665,6 +665,24 @@ class Validate } } + /** + * 通过回调方法验证某个字段是否必须 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function requireCallback($value, $rule, $data) + { + $result = call_user_func_array($rule, [$value, $data]); + if ($result) { + return !empty($value); + } else { + return true; + } + } + /** * 验证某个字段有值的情况下必须 * @access protected