diff --git a/System/Application.php b/System/Application.php index 5a46d643..ce5ed1b3 100644 --- a/System/Application.php +++ b/System/Application.php @@ -44,6 +44,7 @@ class Application extends BaseApplication */ public function __construct(array $config = []) { + instance_load(); parent::__construct($config); } diff --git a/System/Snowflake.php b/System/Snowflake.php index 87ff9522..d7aa49ce 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -335,7 +335,11 @@ class Snowflake */ public static function setAutoload($class, $file) { + if (isset(static::$_autoload[$class])) { + return; + } static::$_autoload[$class] = $file; + include_once "$file"; } @@ -355,12 +359,5 @@ class Snowflake } -$content = json_decode(file_get_contents(__DIR__ . '/../composer.json'), true); -if (isset($content['autoload']) && isset($content['autoload']['psr-4'])) { - $psr4 = $content['autoload']['psr-4']; - foreach ($psr4 as $namespace => $dirname) { - classAutoload($namespace, __DIR__ . '/' . $dirname); - } -} spl_autoload_register([Snowflake::class, 'autoload'], true, true); Snowflake::$container = new Container(); diff --git a/function.php b/function.php index 01e2b7ac..232c056d 100644 --- a/function.php +++ b/function.php @@ -69,6 +69,22 @@ if (!function_exists('loadByDir')) { } +if (!function_exists('instance_load')) { + + function instance_load() + { + $content = json_decode(file_get_contents(__DIR__ . '/../composer.json'), true); + if (isset($content['autoload']) && isset($content['autoload']['psr-4'])) { + $psr4 = $content['autoload']['psr-4']; + foreach ($psr4 as $namespace => $dirname) { + classAutoload($namespace, __DIR__ . '/' . $dirname); + } + } + } + +} + + if (!function_exists('exif_imagetype')) { /**