From 86df3868fb32711dc30cbfc9d46a82873d2054ad Mon Sep 17 00:00:00 2001 From: Guan Xiying Date: Thu, 20 Oct 2022 10:28:35 +0800 Subject: [PATCH] * Refactor the magic method to support call static method. Only static methods of classes declared in a zen file or an ext zen file or a tao file or an ext tao file can be called. --- framework/control.class.php | 4 +++- framework/model.class.php | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index 747a1e12f6..ae729ac382 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -666,8 +666,10 @@ class control extends baseControl { global $app; $moduleName = $app->getModuleName(); - $zenClass = $moduleName . 'Zen'; + $zenClass = 'ext' . $moduleName . 'Zen'; + if(is_callable("{$zenClass}::{$method}")) return call_user_func_array("{$zenClass}::{$method}", $arguments); + $zenClass = $moduleName . 'Zen'; if(is_callable("{$zenClass}::{$method}")) return call_user_func_array("{$zenClass}::{$method}", $arguments); $app->triggerError("the module {$moduleName} has no {$method} method", __FILE__, __LINE__, $exit = true); diff --git a/framework/model.class.php b/framework/model.class.php index d120e4b7c1..062cf998c9 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -367,9 +367,11 @@ class model extends baseModel public static function __callStatic($method, $arguments) { global $app; - $moduleName = $app->getModuleName(); - $taoClass = $moduleName . 'Tao'; + $moduleName = get_called_class(); + $taoClass = 'ext' . $moduleName . 'Tao'; + if(is_callable("{$taoClass}::{$method}")) return call_user_func_array("{$taoClass}::{$method}", $arguments); + $taoClass = $moduleName . 'Tao'; if(is_callable("{$taoClass}::{$method}")) return call_user_func_array("{$taoClass}::{$method}", $arguments); $app->triggerError("the module {$moduleName} has no {$method} method", __FILE__, __LINE__, $exit = true);