| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- declare(strict_types=1);
- namespace SixShop\Core;
- use Random\RandomException;
- use SixShop\Core\Exception\LogicException;
- use think\Paginator;
- use think\Response;
- /**
- * 助手类
- * @deprecated 类已弃用, 请使用函数版本的助手方法
- */
- final class Helper
- {
- /**
- * 返回成功数据
- * @deprecated 函数已弃用, 请使用 success_response()
- */
- public static function success_response(mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success', string $type = 'json', string $xslt = ''): Response
- {
- return success_response($data, $status, $code, $msg, $type, $xslt);
- }
- /**
- * 返回分页数据
- * @deprecated 函数已弃用, 请使用 page_response()
- */
- public static function page_response(Paginator $page, mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success'): Response
- {
- return json([
- 'code' => $code,
- 'status' => $status,
- 'msg' => $msg,
- 'page' => $page,
- 'data' => $data
- ]);
- }
- /**
- * 抛出逻辑异常
- * @throws LogicException
- * @deprecated 函数已弃用, 请使用 throw_logic_exception()
- */
- 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));
- }
- /**
- * 返回失败数据
- * @deprecated 函数已弃用, 请使用 error_response()
- */
- public static function error_response(string $msg = 'error', string $status = 'error', int $code = 1, mixed $data = [], int $httpCode = 400, $header = [], $options = []): Response
- {
- return json([
- 'code' => $code,
- 'status' => $status,
- 'msg' => $msg,
- 'data' => $data
- ], $httpCode, $header, $options);
- }
- /**
- * 构建树形结构选项
- * @param array $data 数据源
- * @param string $valueField 值字段
- * @param string $labelField 标签字段
- * @param string $parentField 父字段
- * @param int $parentId 父ID
- * @param string $childrenKey 子节点键
- * @param bool $preserveOriginal 是否保留原始数据
- *
- * @deprecated 函数已弃用, 请使用 build_tree_options()
- */
- public static function build_tree_options(
- array $data,
- string $valueField = 'id',
- string $labelField = 'name',
- string $parentField = 'parent_id',
- int $parentId = 0,
- string $childrenKey = 'children',
- bool $preserveOriginal = true
- ): array
- {
- return build_tree_options($data, $valueField, $labelField, $parentField, $parentId, $childrenKey, $preserveOriginal);
- }
- /**
- * 生成随机密码
- * @param int $length 密码长度
- * @return string 生成的密码
- * @throws RandomException
- * @deprecated 函数已弃用, 请使用 secret_password()
- */
- public static function secret_password(int $length = 16): string
- {
- return secret_password($length);
- }
- /**
- * 获取插件目录
- * @param string $extensionID 插件ID
- * @return string 插件目录
- * @deprecated 函数已弃用, 请使用 extension_path()
- */
- public static function extension_path(string $extensionID = ''): string
- {
- return extension_path($extensionID);
- }
- /**
- *
- * @deprecated 废弃方法,请使用 extension_name_list 方法
- */
- public static function extension_name_list(): array
- {
- return extension_name_list();
- }
- }
|