From d58e223341b7daaa700662828f510209cb09ea96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 16 Sep 2020 11:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Snowflake.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/System/Snowflake.php b/System/Snowflake.php index 397d349b..e35947f2 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -326,5 +326,37 @@ class Snowflake } + private static $_autoload = []; + + + /** + * @param $class + * @param $file + */ + public static function setAutoload($class, $file) + { + if (isset(static::$_autoload[$class])) { + return; + } + static::$_autoload[$class] = $file; + include_once "$file"; + } + + + /** + * @param $className + */ + public static function autoload($className) + { + if (!isset(static::$_autoload[$className])) { + return; + } + $file = static::$_autoload[$className]; + include_once "$file"; + } + + } + +spl_autoload_register([Snowflake::class, 'autoload'], true, true); Snowflake::$container = new Container();