39 lines
880 B
PHP
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;
|
|
}
|
|
}
|