Browse Source

refactor(core):优化插件加载路径获取逻辑- 将类加载器路径获取方式从 ClassLoader::getRegisteredLoaders() 更换为 InstalledVersions::getInstallPath()
- 调整文件路径拼接方式,确保兼容不同环境下的 composer 安装路径
- 提高代码可维护性和路径获取的准确性

runphp 5 months ago
parent
commit
c352adc1a8
1 changed files with 2 additions and 3 deletions
  1. 2 3
      src/Plugin.php

+ 2 - 3
src/Plugin.php

@@ -3,7 +3,6 @@ declare(strict_types=1);
 
 namespace SixShop\Core;
 
-use Composer\Autoload\ClassLoader;
 use Composer\Composer;
 use Composer\EventDispatcher\EventSubscriberInterface;
 use Composer\InstalledVersions;
@@ -33,8 +32,8 @@ class Plugin implements PluginInterface, EventSubscriberInterface
         if (self::$installedSixShopExtensions) {
             return self::$installedSixShopExtensions;
         }
-        $vendorDir = key(ClassLoader::getRegisteredLoaders());
-        $filePath = $vendorDir . '/composer/installedSixShop.php';
+        $composerDir = dirname(InstalledVersions::getInstallPath('composer/composer'),2);
+        $filePath = $composerDir . '/installedSixShop.php';
         if (file_exists($filePath)) {
             return self::$installedSixShopExtensions = require $filePath;
         }