Sfoglia il codice sorgente

refactor(core): 重构核心模块

- 移除了 composer.json 中的多余配置
- 新增了 CoreExtensionInterface 接口
- 更新了 Extension 类,使其实现 CoreExtensionInterface
- 优化了 Helper 类,添加了类型声明和注释
- 改进了 extension_path 函数,增加了模块参数
runphp 7 mesi fa
parent
commit
af127e5cf0
4 ha cambiato i file con 18 aggiunte e 9 eliminazioni
  1. 1 4
      composer.json
  2. 8 0
      src/Contracts/CoreExtensionInterface.php
  3. 3 1
      src/Extension.php
  4. 6 4
      src/Helper.php

+ 1 - 4
composer.json

@@ -22,10 +22,7 @@
         "think": {
             "services": [
                 "SixShop\\Core\\Service\\CoreService"
-            ],
-            "config":{
-                "captcha": "src/config.php"
-            }
+            ]
         }
     }
 }

+ 8 - 0
src/Contracts/CoreExtensionInterface.php

@@ -0,0 +1,8 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Core\Contracts;
+
+interface CoreExtensionInterface
+{
+
+}

+ 3 - 1
src/Extension.php

@@ -4,7 +4,9 @@ declare(strict_types=1);
 namespace SixShop\Core;
 
 
-class Extension extends ExtensionAbstract
+use SixShop\Core\Contracts\CoreExtensionInterface;
+
+class Extension extends ExtensionAbstract implements CoreExtensionInterface
 {
     protected function getBaseDir(): string
     {

+ 6 - 4
src/Helper.php

@@ -3,6 +3,7 @@ declare(strict_types=1);
 
 namespace SixShop\Core;
 
+use phpDocumentor\Reflection\Types\Self_;
 use SixShop\Core\Exception\LogicException;
 use SixShop\Core\Response\Xml;
 use SixShop\Core\Service\CoreService;
@@ -10,7 +11,7 @@ use think\Container;
 use think\Paginator;
 use think\Response;
 
-class Helper
+final class Helper
 {
 
     /**
@@ -66,10 +67,11 @@ class Helper
 
     /**
      * 抛出逻辑异常
+     * @throws LogicException
      */
     public static function throw_logic_exception(string $msg = 'error', int $code = 1, string $status = 'error', mixed $data = [], int $httpCode = 200, $header = [], $options = []): void
     {
-        throw new LogicException(error_response($msg, $status, $code, $data, $httpCode, $header, $options));
+        throw new LogicException(self::error_response($msg, $status, $code, $data, $httpCode, $header, $options));
     }
 
     /**
@@ -154,9 +156,9 @@ class Helper
     }
 
 
-    public static function extension_path()
+    public static function extension_path(string $module = ''): string
     {
-        return CoreService::$extensionPath;
+        return CoreService::$extensionPath . $module . '/';
     }
 
     public static function extension_name_list()