*/ public static array $extensionComposerMap = []; /* @deprecated */ public static array $extensionNameList = []; private static array $normalExtensionNameList = []; public function register(): void { $this->app->bind(Handle::class, ExceptionHandle::class); $this->app->bind('think\Request', Request::class); $this->app->bind('classLoader', require $this->app->getRootPath() . 'vendor/autoload.php'); self::$extensionPath = $this->app->getRootPath() . 'extension' . DIRECTORY_SEPARATOR; $this->initExtensionList(); $this->compatibleExtensionNameList(); } public function boot(): void { $this->app->make(AutoloadService::class)->load(self::$extensionComposerMap,self::$normalExtensionNameList); $this->app->make(HookAttributeService::class)->init(); $this->app->event->trigger('hook_init', $this->app); $this->app->event->listen(HttpRun::class, function () { $this->registerRoutes($this->app->make(RegisterRouteService::class)->init($this->app)); }); $this->app->make(CommandService::class)->init(function ($commands) { $this->commands($commands); }); } private function initExtensionList(): void { if (!empty(self::$extensionComposerMap)) { return; } $reference = Plugin::getInstalledSixShopExtensions()['root']['reference']; $extensionComposerFile = $this->app->getRootPath() . 'runtime/extension_' .$reference.'.php'; if (file_exists($extensionComposerFile)) { self::$extensionComposerMap = require $extensionComposerFile; return; } foreach (InstalledVersions::getInstalledPackagesByType(Plugin::EXTENSION_TYPE) as $item) { //$version = InstalledVersions::getInstallPath($item); $installPath = InstalledVersions::getInstallPath($item); $composerJson = new JsonFile($installPath . '/composer.json'); $composer = $composerJson->read(); $extensionID = $composer['extra']['sixshop']['id']; self::$extensionComposerMap[$extensionID] = $composer; }; $header = '// This file is automatically generated at:' . date('Y-m-d H:i:s') . PHP_EOL . 'declare (strict_types = 1);' . PHP_EOL; $content = 'app->getRootPath() . 'runtime/module_name_list_normal.php'; if (file_exists($normalFile)) { $normalExtensionList = require $normalFile; foreach ($normalExtensionList as $item) { if (array_key_exists($item, self::$extensionComposerMap)) { continue; } if (is_dir( Helper::extension_path($item).'src')) { self::$extensionNameList[] = $item; self::$normalExtensionNameList[] = $item; } } } } } }