Files
wh-api/app/Constants/AbsConst.php
ykxiao 0b2299c427
Some checks failed
Build Docker / build (push) Has been cancelled
协程版仓库后端项目
2025-07-08 14:59:47 +08:00

39 lines
880 B
PHP

<?php
/**
* Author: ykxiao
* Date: 2024/3/6
* Time: 11:08
* Description:
*/
declare(strict_types=1);
namespace App\Constants;
use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\ConstantsCollector;
class AbsConst extends AbstractConstants
{
/**
* 获取所有常量的键值对列表.
*/
public static function getConstantsList(): array
{
$class = static::class;
$constants = ConstantsCollector::list();
$list = [];
if (isset($constants[$class])) {
foreach ($constants[$class] as $name => $value) {
// 确保获取的是当前常量对应的消息
$message = $value['message'] ?? '';
$list[] = [
'label' => $message,
'value' => $name,
];
}
}
return $list;
}
}