|
|
@@ -12,23 +12,17 @@ use SixShop\Core\Plugin;
|
|
|
use SixShop\Core\Request;
|
|
|
use think\event\HttpRun;
|
|
|
use think\exception\Handle;
|
|
|
+use think\facade\Log;
|
|
|
use think\Service;
|
|
|
use function SixShop\Core\extension_path;
|
|
|
|
|
|
class CoreService extends Service
|
|
|
{
|
|
|
- public static string $extensionPath;
|
|
|
-
|
|
|
/**
|
|
|
* @var array<string, array{name:string,version:string}>
|
|
|
*/
|
|
|
public static array $extensionComposerMap = [];
|
|
|
|
|
|
- /* @deprecated */
|
|
|
- public static array $extensionNameList = [];
|
|
|
-
|
|
|
- private static array $normalExtensionNameList = [];
|
|
|
-
|
|
|
public static function getExtensionComposerMap(): array
|
|
|
{
|
|
|
return self::$extensionComposerMap;
|
|
|
@@ -43,9 +37,7 @@ class CoreService extends Service
|
|
|
$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();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -71,7 +63,12 @@ class CoreService extends Service
|
|
|
}
|
|
|
foreach (InstalledVersions::getInstalledPackagesByType(Plugin::EXTENSION_TYPE) as $item) {
|
|
|
$installPath = InstalledVersions::getInstallPath($item);
|
|
|
- $composerJson = new JsonFile($installPath . '/composer.json');
|
|
|
+ try {
|
|
|
+ $composerJson = new JsonFile($installPath . '/composer.json');
|
|
|
+ } catch (\RuntimeException $e) {
|
|
|
+ Log::error($e->getMessage());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$composer = $composerJson->read();
|
|
|
$extensionID = $composer['extra']['sixshop']['id'] ?? $composer['name'];
|
|
|
self::$extensionComposerMap[$extensionID] = $composer;
|
|
|
@@ -81,37 +78,15 @@ class CoreService extends Service
|
|
|
file_put_contents($extensionComposerFile, $content);
|
|
|
}
|
|
|
|
|
|
- /* @deprecated */
|
|
|
- private function compatibleExtensionNameList(): void
|
|
|
- {
|
|
|
- if (empty(self::$extensionNameList)) {
|
|
|
- self::$extensionNameList = array_keys(self::$extensionComposerMap);
|
|
|
- $normalFile = $this->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(extension_path($item) . 'src')) {
|
|
|
- self::$extensionNameList[] = $item;
|
|
|
- self::$normalExtensionNameList[] = $item;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @throws ReflectionException
|
|
|
*/
|
|
|
public function boot(): void
|
|
|
{
|
|
|
$autoloadService = $this->app->make(AutoloadService::class);
|
|
|
- $invalidExtensionIDs = $autoloadService->load(self::$extensionComposerMap, self::$normalExtensionNameList);
|
|
|
- self::$extensionNameList = array_diff(self::$extensionNameList, $invalidExtensionIDs);
|
|
|
+ $invalidExtensionIDs = $autoloadService->load(self::$extensionComposerMap);
|
|
|
$this->app->get('extension.system')->boot();
|
|
|
- foreach (self::$extensionComposerMap + self::$normalExtensionNameList as $moduleName => $_) {
|
|
|
+ foreach (self::$extensionComposerMap as $moduleName => $_) {
|
|
|
if (in_array($moduleName, $invalidExtensionIDs)) {
|
|
|
continue;
|
|
|
}
|