Browse Source

refactor(extension): 重构扩展路径获取逻辑并移除普通扩展列表接口

- 移除 extension_path 函数的默认参数并调整其行为
- 当扩展不存在时抛出 RuntimeException 异常
- 删除 ExtensionController 中的 normal 方法及相关路由
- 简化扩展路径解析逻辑,去除冗余条件判断
runphp 3 months ago
parent
commit
b50b058942
1 changed files with 2 additions and 5 deletions
  1. 2 5
      src/functions.php

+ 2 - 5
src/functions.php

@@ -162,11 +162,8 @@ function secret_password(int $length = 16): string
 /**
  * 获取扩展路径
  */
-function extension_path(string $extensionID = ''): string
+function extension_path(string $extensionID): string
 {
-    if (!$extensionID) {
-        return CoreService::$extensionPath;
-    }
     if (isset(CoreService::$extensionComposerMap[$extensionID]['name'])) {
         $extensionName = CoreService::$extensionComposerMap[$extensionID]['name'];
         $versions = Plugin::getInstalledSixShopExtensions()['versions'];
@@ -174,7 +171,7 @@ function extension_path(string $extensionID = ''): string
             return realpath($versions[$extensionName]['install_path']) . DIRECTORY_SEPARATOR;
         }
     }
-    return CoreService::$extensionPath . $extensionID . DIRECTORY_SEPARATOR;
+    throw new \RuntimeException('Extension not found');
 }