This commit is contained in:
38
app/Constants/AbsConst.php
Normal file
38
app/Constants/AbsConst.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user